我需要帮助提交一个表单,其中我有检查电子邮件是否存在于下拉列表中,同时提交它显示警报消息的表单但也提交表单,当没有显示警报消息时,只需要提交表单
$(document).on('click', '#Records', function (event) {
$("#dropval select option:selected").each(function () {
var z = $(this).val();
//alert(z);
if(z != 'email') {
alert('please select Email');
e.preventDefault();
return false;
} else {
return true;
}
});
});
});
<form name="search" method="post" action="sample1.php" >
<div id="dropval">
<select name="select3[1]" class="mySelects" >
<option value="None" selected > None</option>
<option value="email" >email</option>
<option value="firstname" >firstname</option>
<option value="lastname" >lastname</option>
<option value="mobile" >mobile</option>
</select>
<select name="select3[2]" class="mySelects" >
<option value="None" selected > None</option>
<option value="email" >email</option>
<option value="firstname" >firstname</option>
<option value="lastname" >lastname</option>
<option value="mobile" >mobile</option>
</select>
<select name="select3[3]" class="mySelects" >
<option value="None" selected > None</option>
<option value="email" >email</option>
<option value="firstname" >firstname</option>
<option value="lastname" >lastname</option>
<option value="mobile" >mobile</option>
</select>
<select name="select3[4]" class="mySelect" >
<option value="None" selected> None</option>
<option value="email" >email</option>
<option value="firstname" >firstname</option>
<option value="lastname" >lastname</option>
<option value="mobile" >mobile</option>
</select>
</div>
<input type="submit" value="submit" id="Records">
</form>