这是我的代码:
$('input#price_match_submit').click(function(event) {
if ($.trim($('input#price_match_competitor_price').val()) == '') {
alert("Please enter competitor's price.");
return false;
}
if ($.trim($('input#price_match_name').val()) == '') {
alert("Please enter your name.");
return false;
}
if ($.trim($('input#price_match_quantity').val()) == '') {
alert("Please enter the quantity.");
return false;
}
if ($.trim($('input#price_match_email').val()) == '') {
alert("Please enter your email address.");
return false;
}
if ($.trim($('input#price_match_competitor_website').val()) == '') {
alert("Please enter competitor's website.");
return false;
}
if ($.trim($('input#price_match_phone_number').val()) == '') {
alert("Please enter your phone number.");
return false;
}
});
这#price_match_submit
是一个提交按钮。当我点击按钮时,这个函数应该执行并验证表单。但它没有像我预期的那样工作。提交表单时未进行任何验证。我在哪里做错了?