欢迎来到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;
}
Tags: , ,
5月2
   嘿嘿jgrin,这几天把用户注册、登陆模块写完了uplook,今天早上开始加正则验证。
网上找了好多正则相关的资料,现在正则验证也写完了,就总结一下:

Email : /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
Phone : /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/,
Mobile : /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/,
Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
IdCard : "this.IsIdCard(value)",
Currency : /^\d+(\.\d+)?$/,
Number : /^\d+$/,
Zip : /^[1-9]\d{5}$/,
QQ : /^[1-9]\d{4,8}$/,
Integer : /^[-\+]?\d+$/,
Double : /^[-\+]?\d+(\.\d+)?$/,
English : /^[A-Za-z]+$/,
Chinese :   /^[\u0391-\uFFE5]+$/,
Username : /^[a-z]\w{3,}$/i,
UnSafe : /^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/,
Tags:
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]