4

Consider the form that are loaded via AJAX. After appending the form to the document I'm calling

$.validator.unobtrusive.parse($form);

and the client validation works like a charm. However there are some scenarios, when I need to change the validation settings, like ignore, so I call

$form.validate({
    ignore: ''
});

$.validator.unobtrusive.parse($form); // and parse with new settings

In this case unobtrusive client validation just doesn't work. What could be the issue?

Edit

"Doesn't work" means, $form.valid() is always true.

0

2 Answers 2

3

I found the solution:

$.validator.unobtrusive.parse($form); // parse the form
var validator = $.data($form[0], 'validator'); // get the form's validator
validator.settings.ignore = ''; // change its settings
Sign up to request clarification or add additional context in comments.

Comments

1

I think this will help.

<div class="editor-field">
   @{ Html.EnableClientValidation(false); }
   @Html.TextBoxFor(m => m.BatchId, new { @class = "k-textbox" })
   @{ Html.EnableClientValidation(true); }</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.