How to bind jQuery.validate.js verification to a dynamically added formCan you help me a lot
If you are using asp.net mvc and use jquery.validate.unobtrusive.js (asp.net mvc’s own validation, something that can be used in combination with class features)
Then you just add this js code before loading the page
//动态表单验证 $(document).ajaxComplete(function () { $.validator.unobtrusive.parse(document); });
Is your form id predictable? If so, just write it in js:
$("#demoForm").validate();
That’s it. If even the ID is dynamically generated, just call the generated id directly in the view:
$("@ViewBag.FormId").validate();
If you are using asp.net mvc and use jquery.validate.unobtrusive.js (asp.net mvc’s own validation, something that can be used in combination with class features)
Then you just add this js code before loading the page
Is your form id predictable? If so, just write it in js:
That’s it. If even the ID is dynamically generated, just call the generated id directly in the view: