这是我的Jsfiddle
实际上,我正在尝试在提交之前验证文本字段。如果文本字段为空,我想显示 errormsg_box,如果不是,则提交表单。但在这里它不起作用这是我的脚本:
$("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;
}
});