我有一个来自jQuery UI的模式对话框,当我按下按钮时出现。下面是关于模态对话框jQuery代码:使用jQuery验证电子邮件
$('#eb1').click(function(){
$('#emailPost').submit();
$("#emailModal").dialog('close');
});
$('#eb2').click(function(){
$('#emailPost2').submit();
$("#emailModal").validate({
rules: {
emailAddress: {
required: true,
email: true
}
}
}).showErrors({"error": "Invalid Email!"});
$("#emailModal").dialog('close');
});
下面是显示所有这一切的PHP:
echo "<form action='php/emailPost.php' method='POST' class='inline' id='emailPost'>";
echo "<input type='hidden' value='" . $_SESSION["email"] . "' name='emailAddress'>";
echo "<input type='button' value='Email To Me' id='eb1'/>";
echo "<input type='hidden' name='passedCoupID' value='" . $coupID . "'/>";
echo "</form>";
echo "<h3>Or</h3>";
echo "<form action='php/emailPost.php' method='POST' class='inline' id='emailPost2'>";
echo "<label name='error'></label>";
echo "<input type='text' value='Enter an Email' class='required email' name='emailAddress' style='display: inline-block;'>";
echo "<input type='button' value='Email' id='eb2'/>";
echo "<input type='hidden' name='passedCoupID' value='" . $coupID . "'/>";
echo "</form>";
我知道的按钮做工精细,以及他们提交完美,但后者的提交不分的验证结果。我很新的jQuery,我如何使它显示一个错误,如果无效,不提交,除非电子邮件有效?