Introduction of JS File
jquery file
<script src= "__public__/static/wap/js/jquery.min.js?v=2.1.4" >
</script>
Form submission Plugin for jquery
<script src= "__public__/static/wap/js/jquery.form.js" >
</script>
Verify JS Class
<script src= "__public__/static/wap/plugins/validate/jquery.validate.min.js" >
</script>
. Newly added validation rules
<script src= "__public__/static/wap/plugins/validate/additional-methods.js" >
</script>
Validation prompt message
<script src= "__public__/static/wap/plugins/validate/messages_zh.min.js" >
</script>
Defines the validation default style JQuery.validator.setDefaults ({highlight:function (e) {///delete error tip style on form elements $ (e). Removeclass ("Err-r"); }, Errorelement: ' Div ', errorclass: ' Er-r ', errorplacement:function (error, Element) {Error.appendto (elem Ent.parent (). Find ('. err ')); }});//Set Background login authentication $ (). Ready (function () {var e = "<i class= ' fa fa-times-circle ' ></i>"; $ ("#login"). Validate ({rules: {mobile: {required:! 0, Ismobile:true}, password: {require D:!0}}, messages: {mobile: {required:e + "phone number must be! ", Ismobile:e +" format Error! "}, Password: {required:e +" password must! "}}, Submithandler:function (form) {var m = $ (" #phone-1 "). Val (); var p = $ ("#pwd-2"). Val (); $ ("#login"). Ajaxsubmit ({type: ' post ',//Submit by Get/post URL: "{: URL (' wap/l Ogin/login ')} ",//URL to submit data: {' mobile ': M, ' Password ':p}, Success function (data) {//data is saved after the commit is returned, typically JSON data//processing is returned with the show_msg (data); } }); return false; Block Form auto-commit event})});
The use of validate in jquery