i want to validate all inputs using class name i’m using following code
$('#submitbutton').click(function() {
$('input.inputme[type=hidden]').each(function () {
if($(this).val()==''){
choclates='false';
}else{
choclates='true';
}
});
if(choclates=='true'){
$('#choclateform').submit();
}else{
alert("Please Fill all Boxes.");
}
});
when i posted this question code was different and was not working full but this works but i think i’m making it complicated can someone make it better ?
If your goal is to prevent a form from being submitted, I’d hook the
submitevent on the form instead, and returnfalsefrom that handler when blank fields are found (to prevent the form being submitted).