欢迎来到Heck's Blog,专业承接拿站、企业建站、仿站、网上商城架构、门户网站搭建、空间域名注册、软件定制等项目。关注网络安全,因为专注,所以专业,懂得放弃,才能收获。有事请发邮件至i@heckjj.com,请记住本站网址:http://www.heckjj.com,多谢。
10月24
首先要引入using System.Text.RegularExpressions;
string pattern = @"^[a-zA-Z0-9]+$";//正则式子
string param1 = null;
Match m = Regex.Match(this.textBox1.Text, pattern); // 匹配正则表达式,把this.textBox1.Text跟pattern正则对比
if (!m.Success) // 判断输入的是不是英文和数字,不是进入
{
param1 = this.textBox1.Text;//将现在textBox的值保存下来
// 将光标定位到文本框的最后
this.textBox1.SelectionStart = this.textBox1.Text.Length;
}
string pattern = @"^[a-zA-Z0-9]+$";//正则式子
string param1 = null;
Match m = Regex.Match(this.textBox1.Text, pattern); // 匹配正则表达式,把this.textBox1.Text跟pattern正则对比
if (!m.Success) // 判断输入的是不是英文和数字,不是进入
{
param1 = this.textBox1.Text;//将现在textBox的值保存下来
// 将光标定位到文本框的最后
this.textBox1.SelectionStart = this.textBox1.Text.Length;
}





