http://blog.sina.com.cn/s/blog_46dd0d320100wzye.html
js验证数字正则表达式
文章分类:Web前端
js验证数字正则表达式
function istrue(a){
var reg=/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*$/i;
return reg.test(a);
}
function
{
}
//检查是否为正数
function
{
}
//检查是否为整数
function
{
}
//检查是否为正整数
function
{
}
//检查是否数字
function isNum(a)
{
}
//检查是否整数
function isInt(a)
{
}
//去掉非法字符
function trim(str)
{
}
//添加部分正则表达式(JQuery)
// 正则规则
"eng" : /^[A-Za-z]+$/,
"chn" :/^[\u0391-\uFFE5]+$/,
"mail" : /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
"url" : /^http[s]?:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
"currency" : /^\d+(\.\d+)?$/,
"number" : /^\d+$/,
"int" : /^[0-9]{1,30}$/,
"double" : /^[-\+]?\d+(\.\d+)?$/,
"username" : /^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/,
"password" : /^(\w){6,20}$/,
"safe" : />|<|,|\[|\]|\{|\}|\?|\/|\+|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i,
"dbc" : /[a-zA-Z0-9!@#¥%^&*()_+{}[]|:"';.,/?<>`~ ]/,
"qq" : /[1-9][0-9]{4,}/,
"date" : /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/,
"year" : /^(19|20)[0-9]{2}$/,
"month" : /^(0?[1-9]|1[0-2])$/,
"day" : /^((0?[1-9])|((1|2)[0-9])|30|31)$/,
"hour" : /^((0?[1-9])|((1|2)[0-3]))$/,
"minute" : /^((0?[1-9])|((1|5)[0-9]))$/,
"second" : /^((0?[1-9])|((1|5)[0-9]))$/,
"mobile" : /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/,
"phone" : /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/,
"zipcode" : /^[1-9]\d{5}$/,
"bodycard" : /^((1[1-5])|(2[1-3])|(3[1-7])|(4[1-6])|(5[0-4])|(6[1-5])|71|(8[12])|91)\d{4}((19\d{2}(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(19\d{2}(0[13578]|1[02])31)|(19\d{2}02(0[1-9]|1\d|2[0-8]))|(19([13579][26]|[2468][048]|0[48])0229))\d{3}(\d|X|x)?$/,
"ip" : /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,
"file": /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,
"image" : /.+\.(jpg|gif|png|bmp)$/i,
"word" : /.+\.(doc|rtf|pdf)$/i,