您的位置:首页 > 其它

一些靠谱的表单正则验证

2012-04-11 09:52 190 查看
function isInteger(obj){

reg=/^[-+]?\d+$/;
if(!reg.test(obj)){
$("#test").html("<b>Please input correct figures</b>");
}else{
$("#test").html("");
}
}

function isEmail(obj){
reg=/^\w{3,}@\w+(\.\w+)+$/;
if(!reg.test(obj)){
$("#test").html("<b>请输入正确的邮箱地址</b>");
}else{
$("#test").html("");
}
}
function isString(obj){
reg=/^[a-z,A-Z]+$/;
if(!reg.test(obj)){
$("#test").html("<b>只能输入字符</b>");
}else{
$("#test").html("");
}
}
function isTelephone(obj){
reg=/^(\d{3,4}\-)?[1-9]\d{6,7}$/;
if(!reg.test(obj)){
$("#test").html("<b>请输入正确的电话号码!</b>");
}else{
$("#test").html("");
}
}
function isMobile(obj){
reg=/^(\+\d{2,3}\-)?\d{11}$/;
if(!reg.test(obj)){
$("#test").html("请输入正确移动电话");
}else{
$("#test").html("");
}
}
function isUri(obj){
reg=/^http:\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
if(!reg.test(obj)){
$("#test").html($("#uri").val()+"请输入正确的inernet地址");
}else{
$("#test").html("");
}
}


关于.NET技术 等其他计算机技术,欢迎加群一起讨论 3群 70536418 2群 5851499 1群 12672376
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: