validationEngine 表单验证插件使用实例代码
程序员文章站
2022-04-10 11:30:14
先给大家展示下效果图,如果大家感觉不错,请参考实现代码:
废话少说,直接上代码,可拷贝直接运行:
先给大家展示下效果图,如果大家感觉不错,请参考实现代码:
废话少说,直接上代码,可拷贝直接运行:
<!doctype html> <html lang="zh"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <title>validationengine 插件</title> <!--<link rel="stylesheet" type="text/css" href="css/validationengine.jquery.css" rel="external nofollow" />--> <link href="https://cdn.bootcss.com/jquery-validation-engine/2.6.4/validationengine.jquery.css" rel="external nofollow" rel="stylesheet"> <style type="text/css"> *{ padding: 0; margin: 0; } #form{ padding-left: 20px; } #form .line{ padding: 10px 0; margin: 10px 0; border-top: 1px dashed #0044cc; } </style> </head> <body> <form action="" method="post" id="form"> <div class='line'> 必填项--输入框 </div> <input value="" class="validate[required]" type="text" name="req"> <div class='line'> 必填项--复选框 </div> <input class="validate[required]" type="checkbox" name="agree">我同意服务协议 <div class='line'> url验证 </div> <input value="http://" class="validate[required,custom[url]]" type="text" name="url"> <div class='line'> email验证 </div> <input value="forced_error" class="validate[required,custom[email]]" type="text" name="email"> <div class='line'> ip 地址(v4) </div> <input value="192.168.3." class="validate[required,custom[ipv4]]" type="text" name="ip"> <div class='line'> 数值 </div> <input value="-33.87a" class="validate[required,custom[number]]" type="text" name="number"> <div class='line'> 整数 </div> <input value="10.1" class="validate[required,custom[integer]]" type="text" name="integer"> <div class='line'> 相等运算 </div> <input value="karnius" class="validate[required]" type="password" name="password" id="password"> <input value="kaniusbad" class="validate[required,equals[password]]" type="password" name="password2" id="password2"> <div class='line'> 限制最小字符数 </div> <input value="" class="validate[required,minsize[6]]" type="text" name="minsize"> <div class='line'> 限制最大字符数 </div> <input value="0123456789" class="validate[optional,maxsize[6]]" type="text" name="maxsize"> <div class='line'> 输入整数(必须大于或等于 -5) </div> <input value="-7" class="validate[required,custom[integer],min[-5]]" type="text" name="min"> <div class='line'> 输入整数(必须小于或等于 50): </div> <input value="55" class="validate[required,custom[integer],max[50]]" type="text" name="max"> </form> <!--<script src="../jquery/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>--> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <!--<script src="js/jquery.validationengine.min.js" type="text/javascript" charset="utf-8"></script>--> <script src="https://cdn.bootcss.com/jquery-validation-engine/2.6.4/jquery.validationengine.min.js"></script> <!--<script src="js/jquery.validationengine-zh_cn.min.js" type="text/javascript" charset="utf-8"></script>--> <script src="https://cdn.bootcss.com/jquery-validation-engine/2.6.4/languages/jquery.validationengine-zh_cn.min.js"></script> <script type="text/javascript"> jquery(document).ready(function() { jquery('#form').validationengine({ scroll: false, promptposition: 'centerright', maxerrorsperfield: 1, showonemessage: true, addpromptclass: 'formerror-noarrow formerror-text' }); }); </script> </body> </html>
以上所述是小编给大家介绍的validationengine 表单验证插件使用实例代码,希望对大家有所帮助
上一篇: 详解AngularJS 模块化
下一篇: JS判断一个数是否是水仙花数