Here is my Jsfiddle.
Actually I am trying to validate a text field before it submits.
I want to show the errormsg_box if the text field is empty, if it’s not then submit a form,
but here it is not working
Here is my script:
$("form").submit(function(event) {
var text_val = $('#emailid').val();
alert(text_val);
if (text_val != ' ') {
$('.errormsg_box').show();
return false;
event.preventdefault();
}
else if (text_val != '') {
$('.errormsg_box').hide();
return true;
}
});
Full code:
Live DEMO
If you want to validte the text is a valid email address:
Live DEMO