0
votes

Now i need to validate dynamically added fields by jquery and my form already has fields with validation in client side and in server side but in same form i added new dynamic inputs during page load but when i add validation to dynamic fields it works but eliminate validation of other fields (not dynamic)

jQuery(document).ready(function () {
    $("#myform").valid();
    $("#i3m29_inpt_ttext").rules("add", {
        required: true,
        minlength: 2,
        messages: {
            required: "Required input",
            minlength: jQuery.validator.format("Please, at least {0} characters are necessary")
        }
    });
});
$("#htmldv").append("<input id='i3m29_inpt_ttext' type='text'>");

So now i need to validate new dynamic fields without affect on validation of other fields that already exist in the form

1
It looks ok to me. It is not clear what the element with id=htmldv is ? Is it part of the form ? - Marco Altieri
yes Mr @MarcoAltieri it's part of the form - Eng Sabreen Saber

1 Answers

0
votes

use this code on success of ajax request. This will validate your form on client side.

OnSuccess = "$.validator.unobtrusive.parse(YourFormID)"

Dont use # symbol for form ID. Hope this will help.