I have a form with tabs about profile, in the about section I have textareas on which I have to perform validation. how to validate on the save button click, I don't want to validate every single textarea like the code below
$(document).ready(function () { $("#btnSaveMyChanges").click(function () {
var valid = true;
if ($("#txtAboutMySelf").val() == "") {
$("#ErrorAboutMySelf").html("This Field is Required.");
valid = false;
}
if ($("#txtAboutMyMatch").val() == "") {
$("#ErrorAboutMyMatch").html("This Field is Required.");
valid = false;
}
if ($("#txtWhatIamDoing").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
if ($("#txtIamReallyGood").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
if ($("#txtTheSixThings").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
if ($("#txtISpendaLot").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
if ($("#txtTheFirstThings").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
if ($("#txtOnaTypicalFriday").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
if ($("#txtMyFriendsDescribe").val() == "") {
$("#errmsg").html("invalide");
valid = false;
}
return valid;
});
});
make a function and then on save click iterate through the form get all the text areas and then perform the required field validation and as well on the keyup event I need the maxlength to be 500 for every text area