js正则表达式验证大全(收集)
发布时间:2016-11-28 09:30:07 所属栏目:大数据 来源:站长网
导读:引用网址nbsp; http://hi.baidu.com/quiteuniverse/blog/item/9f3f043d46ad1e07bba16716.html 以下函数调用方式:nbsp;nbsp;nbsp; function check() { var bb = document.getElementById("txt_id").value;//txt_id为文本框的ID alert(ismobile(bb));//ismo
nbsp;//nbsp;不为空 function checkElement_NotNull(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_NotNull(v,a,w,g)); } function checkValue_NotNull(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=NotNull(v); return(checkBoolean(bv,i,w)); } nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; // 合法邮箱 function checkElement_IsEmail(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsEmail(v,a,w,g)); } function checkValue_IsEmail(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=checkEmail(v); return(checkBoolean(bv,i,w)); } nbsp;// 合法身份证 function checkElement_IsIDCard(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsIDCard(v,a,w,g)); } function checkValue_IsIDCard(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=checkIDCard(v); return(checkBoolean(bv,i,w)); } // 合法 IP function checkElement_IsIP(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsIP(v,a,w,g)); } function checkValue_IsIP(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=checkIP(v); return(checkBoolean(bv,i,w)); } // 验证数字 function checkElement_IsNum(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsNum(v,a,w,g)); } function checkValue_IsNum(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=isNum(v); return(checkBoolean(bv,i,w)); } // 验证整数 function checkElement_IsInt(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsInt(v,a,w,g)); } function checkValue_IsInt(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=isInt(v); return(checkBoolean(bv,i,w)); } // 验证字母 function checkElement_IsChar(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsChar(v,a,w,g)); } function checkValue_IsChar(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=isChar(v); return(checkBoolean(bv,i,w)); } // 合法主页 function checkElement_IsHomepage(a,alert_str,g) { v=a.value; w=alert_str; if(alert_str.length==0)w=a.title+"不能为空!"; return(checkValue_IsHomepage(v,a,w,g)); } function checkValue_IsHomepage(v,i,w,g) { if(g!="NOT_TRIM")v=v.replace(/(^s*)|(s*$)/g, ""); bv=checkHomepage(v); return(checkBoolean(bv,i,w)); } (编辑:淮北站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |