【发布时间】:2010-01-21 21:24:05
【问题描述】:
我有以下功能:
function checkEmails(newEmail){
$('table td:nth-child(3)').each(function(){
if ($(this).html() == newEmail)
{
alert('The email address "' + newEmail + '" is already in the list. Duplicates are not allowed.');
toggleSpinner();
return false;
}
});
return true;
}
我在我的表单提交处理程序中这样调用它:
if (!checkEmails($('input#email', $('#newForm')).val())) {
return false;
}//I submit the form via ajax next....
我只是在检查以确保用户尝试提交的电子邮件地址不在表格中。它似乎工作得很好,除了在 Firefox 中,它实际上并没有阻止 ajax 请求的发生。出现警告框,告诉我用户已经在列表中,但单击确定后,表单仍然提交。它可以在 IE 中按我想要的方式工作。
我在这里做错了什么?
【问题讨论】:
标签: javascript jquery