formValidate输⼊验证
<html xmlns="/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jQuery formValidator表单验证插件 -- by:猫冬,email:wzmaodong@126</title>
<meta name="Author" content="猫冬">
<meta name="description" content="jQuery formValidator表单验证插件" />
<meta name="keywords" content="jQuery,formValidator,插件,表单,验证,插件,javascript,表单验证,提⽰层" />
<script src="jquery_last.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="style/validator.css"></link>
<script src="formValidator.js" type="text/javascript" charset="UTF-8"></script>
<script src="formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function(){
$.formValidator.initConfig({formid:"form1",onerror:function(){alert("校验没有通过,具体错误请看错误提⽰")}});
$("#sfz").formValidator({onshow:"请输⼊15或18位的⾝份证",onfocus:"输⼊15或18位的⾝份证",oncorrect:"输⼊正
确"}).regexValidator({regexp:"idcard",datatype:"enum",onerror:"你输⼊的⾝份证格式不正确"});;
$("#sfz1").formValidator({onshow:"请输⼊15或18位的⾝份证",onfocus:"输⼊15或18位的⾝份证",oncorrect:"输⼊正确"}).functionValidator({fun:isCardID});
$("#zs").formValidator({onshow:"请输⼊整数",oncorrect:"谢谢你的合作,你的整数正确"}).regexValidator({regexp:"intege",datatype:"enum",onerror:"整数格式不正确"});
$("#zzs").formValidator({onshow:"请输⼊正整数",oncorrect:"谢谢你的合作,你的正整数正
确"}).regexValidator({regexp:"intege1",datatype:"enum",onerror:"正整数格式不正确"});
$("#fzs").formValidator({onshow:"请输⼊负整数",oncorrect:"谢谢你的合作,你的负整数正
确"}).regexValidator({regexp:"intege2",datatype:"enum",onerror:"负整数格式不正确"});
$("#sz").formValidator({onshow:"请输⼊数字",oncorrect:"谢谢你的合作,你的数字正确"}).regexValidator({regexp:"num",datatype:"enum",onerror:"数字格式不正确"});
$("#zs1").formValidator({onshow:"请输⼊正数",oncorrect:"谢谢你的合作,你的正数正确"}).regexValidator({regexp:"num1",datatype:"enum",onerror:"正数格式不正确"});
$("#fs").formValidator({onshow:"请输⼊负数",oncorrect:"谢谢你的合作,你的负数正确"}).regexValidator({regexp:"num2",datatype:"enum",onerror:"负数格式不正确"});
$("#sj").formValidator({onshow:"请输⼊你的⼿机号码",onfocus:"必须是13或15打头哦",oncorrect:"谢谢你的合作,你的⼿机号码正
确"}).regexValidator({regexp:"mobile",datatype:"enum",onerror:"⼿机号码格式不正确"});
/
/$("#").formValidator({onshow:"",onfocus:"请输⼊",oncorrect:"谢谢你的合作,你的正确"}).regexValidator({regexp:"",datatype:"enum",onerror:"格式不正确"});
$("#email").formValidator({onshow:"请输⼊你的email",onfocus:"请注意你输⼊的email格式,例如:wzmaodong@126",oncorrect:"谢谢你的合作,你的email正确"}).regexValidator({regexp:"email",datatype:"enum",onerror:"email格式不正确"});
$("#fds").formValidator({onshow:"请输⼊浮点数",oncorrect:"谢谢你的合作,你的浮点数正
确"}).regexValidator({regexp:"decmal",datatype:"enum",onerror:"浮点数格式不正确"});
$("#zfds").formValidator({onshow:"请输⼊正浮点数",oncorrect:"谢谢你的合作,你的正浮点数正
确"}).regexValidator({regexp:"decmal1",datatype:"enum",onerror:"正浮点数格式不正确"});
$("#ffds").formValidator({onshow:"请输⼊负浮点数",oncorrect:"谢谢你的合作,你的负浮点数正
确"}).regexValidator({regexp:"decmal2",datatype:"enum",onerror:"负浮点数格式不正确"});
$("#fffds").formValidator({onshow:"请输⼊⾮负浮点数",oncorrect:"谢谢你的合作,你的⾮负浮点数正
确"}).regexValidator({regexp:"decmal4",datatype:"enum",onerror:"⾮负浮点数格式不正确"});
$("#fzfds").formValidator({onshow:"请输⼊⾮正浮点数",oncorrect:"谢谢你的合作,你的⾮正浮点数正
确"}).regexValidator({regexp:"decmal5",datatype:"enum",onerror:"⾮正浮点数格式不正确"});
$("#ys").formValidator({onshow:"请输⼊16进制颜⾊",oncorrect:"谢谢你的合作,你的16进制颜⾊正
确"}).regexValidator({regexp:"color",datatype:"enum",onerror:"16进制颜⾊格式不正确"});
确"}).regexValidator({regexp:"ip4",datatype:"enum",onerror:"ip4格式不正确"});
$("#fk").formValidator({onshow:"请输⼊⾮空字符",oncorrect:"谢谢你的合作,你的⾮空字符正
确"}).regexValidator({regexp:"notempty",datatype:"enum",onerror:"⾮空字符格式不正确"});
$("#tp").formValidator({onshow:"请输⼊图⽚名",oncorrect:"谢谢你的合作,你的图⽚名正
确"}).regexValidator({regexp:"picture",datatype:"enum",onerror:"图⽚名格式不正确"});
$("#rar").formValidator({onshow:"请输⼊压缩⽂件名",oncorrect:"谢谢你的合作,你的压缩⽂件名正
确"}).regexValidator({regexp:"rar",datatype:"enum",onerror:"压缩⽂件名格式不正确"});
$("#qq").formValidator({onshow:"请输⼊QQ号码",oncorrect:"谢谢你的合作,你的QQ号码正
确"}).regexValidator({regexp:"qq",datatype:"enum",onerror:"QQ号码格式不正确"});
$("#dh").formValidator({onshow:"请输⼊国内电话",onfocus:"例如:0577-********或省略区号88888888",oncorrect:"谢谢你的合作,你的国内电话正确"}).regexValidator({regexp:"tel",datatype:"enum",onerror:"国内电话格式不正确"});
$("#yhm").formValidator({onshow:"请输⼊⽤户名",oncorrect:"谢谢你的合作,你的⽤户名正
确"}).regexValidator({regexp:"username",datatype:"enum",onerror:"⽤户名格式不正确"});
$("#zm").formValidator({onshow:"请输⼊字母",oncorrect:"谢谢你的合作,你的字母正确"}).regexValidator({regexp:"letter",datatype:"enum",onerror:"字母格式不正确"});
$("#dxzm").formValidator({onshow:"请输⼊⼤写字母",oncorrect:"谢谢你的合作,你的⼤写字母正
确"}).regexValidator({regexp:"letter_u",datatype:"enum",onerror:"⼤写字母格式不正确"});
$("#xxzm").formValidator({onshow:"请输⼊⼩写字母",oncorrect:"谢谢你的合作,你的⼩写字母正
确"}).regexValidator({regexp:"letter_l",datatype:"enum",onerror:"⼩写字母格式不正确"});
$("#sfz").formValidator({onshow:"请输⼊⾝份证",oncorrect:"谢谢你的合作,你的⾝份证正
确"}).regexValidator({regexp:"idcard",datatype:"enum",onerror:"⾝份证格式不正确"});
});
</script>
<style type="text/css" media="all">
body,div{font-size:12px; margin:10px;}
</style>
</head>
<body>
<h2>如何调⽤扩展库</h2>
<p>正则表达式⽰例</p>
<p><a href="wzmaodongblogs">猫冬的博客</a></p>
<form action="" method="post" name="form1" id="form1">
<table border="0px" >
<tr>
<td colpan="3"><input type="submit" name="button" id="button" value="提交" /></td>
</tr>
<tr>
<td align="right">⾝份证(正则表达式库):</td>
<td><input name="sfz" type="text" id="sfz" /></td>
<td><div id="sfzTip" ></div></td>
</tr>
<tr>
<td align="right">⾝份证(外部函数):</td>
<td><input type="text" id="sfz1" /></td>
<td><div id="sfz1Tip" ></div></td>
</tr>
<tr>
<td align="right">整数:</td>
<td><input type="text" id="zs" /></td>
<td><div id="zsTip" ></div></td>
</tr>
<td><input type="text" id="fzs" /></td>      <td><div id="fzsTip" ></div></td>
</tr>
<tr>
<td align="right">数字:</td>
<td><input type="text" id="sz" /></td>      <td><div id="szTip" ></div></td>
</tr>
<tr>
<td align="right">正数(正整数 + 0):</td>
<td><input type="text" id="zs1" /></td>      <td><div id="zs1Tip" style="width:300p
x"></div></td>
</tr>
<tr>
<td align="right">负数(负整数 + 0):</td>
<td><input type="text" id="fs" /></td>      <td><div id="fsTip" ></div></td>
</tr>
<tr>
<td align="right">浮点数:</td>
<td><input type="text" id="fds" /></td>      <td><div id="fdsTip" ></div></td>
</tr>
<tr>
<td align="right">正浮点数:</td>
<td><input type="text" id="zfds" /></td>      <td><div id="zfdsTip" ></div></td>
html表单只能输入数字</tr>
<tr>
<td align="right">负浮点数:</td>
<td><input type="text" id="ffds" /></td>      <td><div id="ffdsTip" ></div></td>
</tr>
<tr>
<td align="right">⾮负浮点数(正浮点数 + 0):</td>
<td><input type="text" id="fffds" /></td>      <td><div id="fffdsTip" ></div></td>
</tr>
<tr>
<td align="right">⾮正浮点数(负浮点数 + 0):</td>
<td><input type="text" id="fzfds" /></td>      <td><div id="fzfdsTip" ></div></td>
</tr>
<tr>
<td align="right">颜⾊:</td>
<td><input type="text" id="ys" /></td>      <td><div id="ysTip" ></div></td>
</tr>
<td><input type="text" id="sj" /></td>      <td><div id="sjTip" ></div></td>
</tr>
<tr>
<td align="right">邮编:</td>
<td><input type="text" id="yb" /></td>      <td><div id="ybTip" ></div></td>
</tr>
<tr>
<td align="right">⾮空:</td>
<td><input type="text" id="fk" /></td>      <td><div id="fkTip" >
</div></td>
</tr>
<tr>
<td align="right">图⽚:</td>
<td><input type="text" id="tp" /></td>      <td><div id="tpTip" ></div></td>
</tr>
<tr>
<td align="right">压缩⽂件:</td>
<td><input type="text" id="rar" /></td>      <td><div id="rarTip" ></div></td>
</tr>
<tr>
<td align="right">ip4:</td>
<td><input type="text" id="ip4" /></td>      <td><div id="ip4Tip" ></div></td>
</tr>
<tr>
<td align="right">QQ号码:</td>
<td><input type="text" id="qq" /></td>      <td><div id="qqTip" ></div></td>
</tr>
<tr>
<td align="right">国内电话:</td>
<td><input type="text" id="dh" /></td>      <td><div id="dhTip" ></div></td>
</tr>
<tr>
<td align="right">⽤户名:</td>
<td><input type="text" id="yhm" /></td>      <td><div id="yhmTip" ></div></td>
</tr>
<tr>
<td align="right">字母:</td>
<td><input type="text" id="zm" /></td>      <td><div id="zmTip" ></div></td>
</tr>
<td align="right">⼩写字母:</td>
<td><input type="text" id="xxzm" /></td>      <td><div id="xxzmTip" ></div></td>
</tr>
<tr>
<td align="right">⾝份证:</td>
<td><input type="text" id="sfz" /></td>      <td><div id="sfzTip" ></div></td>
</tr>
<tr>
</table>
</form>
</body>
</html>
版权声明:本⽂为博主原创⽂章,未经博主允许不得转载。