I want to perform client-side validation of a simple form using jQuery, but I can\'t use any plugins for validation. I want to display any error messages in a single alert
If you only want 1 alert to appear at a time you need to check the state of valid for each condition:
$('#submit').on('click', function() {
valid = true;
if (valid && $('#name').val() == '') {
alert ("please enter your name");
valid = false;
}
if (valid && $('#address').val() == '') {
alert ("please enter your address");
valid = false;
}
return valid;
});
Updated fiddle