-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md.bak
28 lines (15 loc) · 1.2 KB
/
README.md.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
jquery.validate.unobtrusive.dynamic
====================================
# Applying unobtrusive jquery validation to dynamic content in ASP.Net MVC
The new unobtrusive validation features of ASP.net MVC are great, but I was surprised to find that once the validators have been applied for a document, validators as a result of dynamic content will not be applied, even if you call `$.validator.unobstrusive.parse`
The Microsoft `jquery.validate.unobtrusive` library calls the jquery `.validate` method on the relevant form. Inside this method, it does nothing if the form already has a validator attached, so any parsed rules will be ignored.
This is small extension
##Examples
For example parse dynamic content like:
$.validator.unobtrusive.parseDynamicContent('input.something');
I also added the ability to remove rules for elements you remove from the dom. So, when you remove elements from the Dom and you want those validation rules removed also then call
$.validator.unobtrusive.unparseContent('input.something');
You cal always reparse whole `FORM` with
$("form").data("unobtrusiveValidation", null);
$("form").data("validator", null);
$.validator.unobtrusive.parse($("form"));