Home > Web Front-end > JS Tutorial > jquery form validation uses plug-in formValidator_form effects

jquery form validation uses plug-in formValidator_form effects

WBOY
Release: 2016-05-16 17:48:22
Original
1177 people have browsed it
1. First add necessary js and css to the project


2. Add a reference (required reference) in the code

Copy code The code is as follows:






3. Tags to be verified in (make some common demonstrations)
Copy code The code is as follows:

















































































































































身份证(正则表达式库):
身份证(外部函数):
整数:
正整数:
负整数:
数字:
正数(正整数 + 0):
负数(负整数 + 0):
浮点数:
正浮点数:
负浮点数:
非负浮点数(正浮点数 + 0):
非正浮点数(负浮点数 + 0):
颜色:
你的EMAIL:
手机:
邮编:
非空:
图片:
压缩文件:
ip4:
QQ号码:
国内电话:
用户名:
字母:
大写字母:
小写字母:
身份证:


4. Code in <script></strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="99306" class="copybut" id="copybut99306" onclick="doCopy('code99306')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code99306"> <br><script type="text/javascript"> <br>$(document).ready(function () { <br>$.formValidator.initConfig({ formID: "form1", onError: function () { alert("The verification failed, please see the error message for specific errors") } }); <br>$("#sfz").formValidator({ onShow: "Please enter a 15 or 18-digit ID card ", onfocus: "Enter the 15 or 18-digit ID card", onCorrect: "The input is correct" }).regexValidator({ regExp: "idcard", dataType: "enum", onError: "The format of the ID card you entered is incorrect " }); ; <br>$("#sfz1").formValidator({ onShow: "Please enter a 15- or 18-digit ID card", onfocus: "Enter a 15- or 18-digit ID card", onCorrect: "Enter Correct" }).functionValidator({ fun: isCardID }); <br>$("#zs").formValidator({ onShow: "Please enter an integer", onCorrect: "Thank you for your cooperation, your integer is correct" } ).regexValidator({ regExp: "intege", dataType: "enum", onError: "The integer format is incorrect" }); <br>$("#zzs").formValidator({ onShow: "Please enter a positive integer" , onCorrect: "Thank you for your cooperation, your positive integer is correct" }).regexValidator({ regExp: "intege1", dataType: "enum", onError: "The positive integer format is incorrect" }); <br>$( "#fzs").formValidator({ onShow: "Please enter a negative integer", onCorrect: "Thank you for your cooperation, your negative integer is correct" }).regexValidator({ regExp: "intege2", dataType: "enum", onError: "Negative integer format is incorrect" }); <br>$("#sz").formValidator({ onShow: "Please enter a number", onCorrect: "Thank you for your cooperation, your number is correct" }). regexValidator({ regExp: "num", dataType: "enum", onError: "The number format is incorrect" }); <br>$("#zs1").formValidator({ onShow: "Please enter a positive number", onCorrect : "Thank you for your cooperation, your positive number is correct" }).regexValidator({ regExp: "num1", dataType: "enum", onError: "The positive number format is incorrect" }); <br>$("# fs").formValidator({ onShow: "Please enter a negative number", onCorrect: "Thank you for your cooperation, your negative number is correct" }).regexValidator({ regExp: "num2", dataType: "enum", onError: "Negative number The format is incorrect" }); <br>$("#sj").formValidator({ onShow: "Please enter your mobile phone number", onfocus: "Must start with 13 or 15", onCorrect: "Thank you Cooperation, your mobile phone number is correct" }).regexValidator({ regExp: "mobile", dataType: "enum", onError: "Mobile phone number format is incorrect" }); <br>//$("#"). formValidator({onShow:"",onfocus:"Please enter",onCorrect:"Thank you for your cooperation, yours is correct"}).regexValidator({regExp:"",dataType:"enum",onError:"The format is incorrect "}); <br>$("#email").formValidator({ onShow: "Please enter your email", onfocus: "Please pay attention to the email format you enter, for example: wzmaodong@126.com", onCorrect: "Thank you for your cooperation, your email is correct" }).regexValidator({ regExp: "email", dataType: "enum", onError: "email format is incorrect" }); <br>$("#fds") .formValidator({ onShow: "Please enter a floating point number", onCorrect: "Thank you for your cooperation, your floating point number is correct" }).regexValidator({ regExp: "decmal", dataType: "enum", onError: "Floating point number The format is incorrect" }); <br>$("#zfds").formValidator({ onShow: "Please enter a positive floating point number", onCorrect: "Thank you for your cooperation, your positive floating point number is correct" }).regexValidator ({ regExp: "decmal1", dataType: "enum", onError: "The format of the positive floating point number is incorrect" }); <br>$("#ffds").formValidator({ onShow: "Please enter a negative floating point number" , onCorrect: "Thank you for your cooperation, your negative floating point number is correct" }).regexValidator({ regExp: "decmal2", dataType: "enum", onError: "The negative floating point number format is incorrect" }); <br> $("#fffds").formValidator({ onShow: "Please enter a non-negative floating point number", onCorrect: "Thank you for your cooperation, your non-negative floating point number is correct" }).regexValidator({ regExp: "decmal4", dataType: "enum", onError: "The format of non-negative floating point numbers is incorrect" }); <br>$("#fzfds").formValidator({ onShow: "Please enter a non-positive floating point number", onCorrect: "Thank you With your cooperation, your non-positive floating-point numbers are correct" }).regexValidator({ regExp: "decmal5", dataType: "enum", onError: "The format of non-positive floating-point numbers is incorrect" }); <br>$("# ys").formValidator({ onShow: "Please enter the hexadecimal color", onCorrect: "Thank you for your cooperation, your hexadecimal color is correct" }).regexValidator({ regExp: "color", dataType: "enum ", onError: "The hexadecimal color format is incorrect" }); <br>$("#yb").formValidator({ onShow: "Please enter the zip code", onfocus: "It consists of 6 digits", onCorrect : "Thank you for your cooperation, your zip code is correct" }).regexValidator({ regExp: "zipcode", dataType: "enum", onError: "The zip code format is incorrect" }); <br>$("#ip4" ).formValidator({ onShow: "Please enter ip4", onfocus: "For example: 172.16.201.18", onCorrect: "Thank you for your cooperation, your ip4 is correct" }).regexValidator({ regExp: "ip4", dataType: "enum", onError: "ip4 format is incorrect" }); <br>$("#fk").formValidator({ onShow: "Please enter non-empty characters", onCorrect: "Thank you for your cooperation, your very The empty character is correct" }).regexValidator({ regExp: "notempty", dataType: "enum", onError: "The format of the non-empty character is incorrect" }); <br>$("#tp").formValidator({ onShow : "Please enter the picture name", onCorrect: "Thank you for your cooperation, your picture name is correct" }).regexValidator({ regExp: "picture", dataType: "enum", onError: "The picture name format is incorrect" }); <br>$("#rar").formValidator({ onShow: "请输入压缩文件名", onCorrect: "谢谢你的合作,你的压缩文件名正确" }).regexValidator({ regExp: "rar", dataType: "enum", onError: "压缩文件名格式不正确" }); <br>$("#qq").formValidator({ onShow: "请输入QQ号码", onCorrect: "谢谢你的合作,你的QQ号码正确" }).regexValidator({ regExp: "qq", dataType: "enum", onError: "QQ号码格式不正确" }); <br>$("#dh").formValidator({ onShow: "请输入国内电话", onfocus: "例如:0577-88888888或省略区号88888888", onCorrect: "谢谢你的合作,你的国内电话正确" }).regexValidator({ regExp: "tel", dataType: "enum", onError: "国内电话格式不正确" }); <br>$("#yhm").formValidator({ onShow: "请输入用户名", onCorrect: "谢谢你的合作,你的用户名正确" }).regexValidator({ regExp: "username", dataType: "enum", onError: "用户名格式不正确" }); <br>$("#zm").formValidator({ onShow: "请输入字母", onCorrect: "谢谢你的合作,你的字母正确" }).regexValidator({ regExp: "letter", dataType: "enum", onError: "字母格式不正确" }); <br>$("#dxzm").formValidator({ onShow: "请输入大写字母", onCorrect: "谢谢你的合作,你的大写字母正确" }).regexValidator({ regExp: "letter_u", dataType: "enum", onError: "大写字母格式不正确" }); <br>$("#xxzm").formValidator({ onShow: "请输入小写字母", onCorrect: "谢谢你的合作,你的小写字母正确" }).regexValidator({ regExp: "letter_l", dataType: "enum", onError: "小写字母格式不正确" }); <br>$("#sfz").formValidator({ onShow: "请输入身份证", onCorrect: "谢谢你的合作,你的身份证正确" }).regexValidator({ regExp: "idcard", dataType: "enum", onError: "身份证格式不正确" }); <br>}); <br></script>

5.效果图:

 
6.

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template