To modify the Jquery.validate prompt error method, use the pop-up box to prompt the error message
<script src= "@Url. Content (" ~/scripts/jquery.validate.js ")" ></script>
<script src= "@Url. Content (" ~/scripts/jquery.validate.unobtrusive.js ")" ></script>
1 $.extend ($.validator.defaults, {2ShowErrors:function(Errormap, errorlist) {3 varmsg = "";4$.each (Errorlist,function(i, v) {5msg + = (v.message + "\ r \ n");6 });7 if(msg! = "")8 alert (msg);9 }Ten});
After the modification, found that the execution is not effective, and does not eject the error message, the information is still displayed behind the text box
After debugging, the custom method is not extended to $.validator,
And the method to be rewritten works, you must refer to the
<script src= "@Url. Content (" ~/scripts/jquery.validate.unobtrusive.js ")" ></script>
Before you can rewrite it.
The complete code is as follows:
1<script src= "@Url. Content (" ~/scripts/jquery.validate.js ")" ></script>2 3<script type= "Text/javascript" >4 $.extend ($.validator.defaults, {5ShowErrors:function(Errormap, errorlist) {6 varmsg = "";7$.each (Errorlist,function(i, v) {8msg + = (v.message + "\ r \ n");9 });Ten if(msg! = "") One alert (msg); A } - }); -</script> the<script src= "@Url. Content (" ~/scripts/jquery.validate.unobtrusive.js ")" ></script>
Jquery.validate Tips Error method