], the custom method extends to [$.validator] middle."/> ], the custom method extends to [$.validator] middle.">
Home >Web Front-end >JS Tutorial >How jquery validate prompts errors
jquery validate prompts an error method: quote [e42227c7768bcba6f5d45ec7d2fea16c2cacc6d41bbb37262a98f745aa00fbf0], The custom method is extended to [$.validator].
Recommendation: "jquery video tutorial"
jquery validate prompts error method:
Modify the jquery.validate prompt error method and use a 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>
$.extend($.validator.defaults, { showErrors: function (errorMap, errorList) { var msg = ""; $.each(errorList, function (i, v) { msg += (v.message + "\r\n"); }); if (msg != "") alert(msg); } });
After the modification, it was found that the execution had no effect and the error message would not pop up. The message was still behind the text box. Display
After debugging, it was found that the custom method was not extended to $.validator
,
and for the overridden method to work, it must be referenced
dceffec6d9979de87ce02bc14cc11ae92cacc6d41bbb37262a98f745aa00fbf0
It can only be rewritten before.
The complete code is as follows:
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script> <script type="text/javascript"> $.extend($.validator.defaults, { showErrors: function (errorMap, errorList) { var msg = ""; $.each(errorList, function (i, v) { msg += (v.message + "\r\n"); }); if (msg != "") alert(msg); } }); </script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
Related free learning recommendations: JavaScript (video)
The above is the detailed content of How jquery validate prompts errors. For more information, please follow other related articles on the PHP Chinese website!