来自:新思网络 时间:2012-07-08 10:55:21
function validateNum(val){//验证整数
var patten = /^-?\d+$/;
return patten.test(val);
}
function validateRealNum(val){//验证实数
var patten = /^-?\d+\.?\d*$/;
return patten.test(val);
}
function validateNum(val){//验证小数,保留一位小数点
var patten = /^-?\d+\.?\d{0,1}$/;
return patten.test(val);
}
function validateFloat(val){//验证小数
var patten = /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/;
return patten.test(val);
}
function validateNumOrLetter(val){//只能输入数字和字母
var patten = /^[A-Za-z0-9]+$/;
return patten.test(val);
}
function validateColor(val){//验证颜色
var patten = /^#[0-9a-fA-F]{6}$/;
return patten.test(val);
}
function validateUrl(val){ //验证URL
var patten = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
return patten.test(val);
}
function validateNull(val){//验证空
return val.replace(/\s+/g, "").length==0;
}
function validateDate(val){//验证时间2010-10-10
var patten = /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/;
return patten.test(val);
}
function validateNumLetterLine(val){//只能输入数字、字母、下划线
var patten = /^[a-zA-Z0-9_]{1,}$/;
return patten.test(val);
}
分类:JavaScript浏览( 2224 )次
电脑故障 | ps教程 | 设计 |
创业 | seo | discuz |
word | 配置 | c# |
数据库 | mysql | asp |
ShopEx | html | JavaScript |
模板 | Joomla | PhotoShop |
CSS | PHP | WordPress |
ECShop | jQuery | 用户体验 |
新闻 | 读书 |
[ html ] div css 高度 宽度 自适应浏......
[ 电脑故障 ] 联想的笔记本电脑不动十分钟,就黑屏了......
[ 设计 ] 国外30款设计精美的网站登录页面模板
[ JavaScript ] js替换函数replace 替换多个......
[ 设计 ] 浅谈—韩国游戏网站设计
[ 创业 ] 内部创业:选择大于努力
[ seo ] 浅谈论坛内容成型的三个特性:模仿性 ......
[ seo ] 利用链接的价值导向来优化网站链接