c# - Adding validation with MVC 3 & jQuery Validator in execution time -


i have form validation rendered c# when page loaded, rendered fields so:

<input autocomplete="off" class="input-validation-error" data-val="true" data-val-number="the field idade must number." data-val-range="message here" data-val-range-max="25" data-val-range-min="16" data-val-required="the idade field required." id="content_myfieldid" maxlength="3" name="content.myfieldid" value="0" type="text"> 

and i'm trying put new html object equals example jquery, new field not validated when submit form.

have way add validation in field using jquery?

ps: don't want use manual method so:

$("#field").rules("add", {     required: true,     messages: {         required: "required input"     } }); 

because have rules in input field, want apply it.

feels bit of hack, here's how i've done it.

// target form var $form = $("**form selector**");  // unbind existing validation $form.unbind(); $form.data("validator", null);  // check document changes $.validator.unobtrusive.parse(document);  // re add validation changes $form.validate($form.data("unobtrusivevalidation").options); 

rich


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -