I am creating input fields with jquery
var randomNum = Math.ceil(Math.random() * 99999);
$("<p class='" + randomNum + "'>First name: <input type='text' name='kontaktFormaIme" + randomNum + "' class='required' id='kontaktFormaIme" + randomNum + "' maxlength='50' /></p>").appendTo(".kontakt");
$("<p class='" + randomNum + "'>Last NameIme: <input type='text' name='kontaktFormaPrezime" + randomNum + "' class='required' id='kontaktFormaPrezime" + randomNum + "' /></p>").appendTo(".kontakt");
with this I can creat as many as I want
What is easy way to check for example every with ID that starts with "kontaktFormaIme" or have class 'required'
But I don' know how to make general checker, I have tried something like this but it is not working
function ValidateKontakt(source, args) {
var isFormValid = true;
$(".required input").each(function () {
if ($.trim($(this).val()).length == 0) {
$(this).addClass("highlight");
isFormValid = false;
}
else {
$(this).removeClass("highlight");
}
});
args.IsValid = isFormValid;
}