【发布时间】:2020-01-25 19:05:43
【问题描述】:
这是我的表格:
<form class="fms-quote-form" action="https://web.com/quotes" method="get">
<input name="wpf126904_18" id="fms-zip" type="number" placeholder="Enter your Zipcode">
<input type="submit" value="Get My Rates">
</form>
我的 jQuery 不工作:
$('.fms-quote-form').submit(function() {
if ( $('#fms-zip').val() >= 90000 AND <=96162 ) {
return true;
} else {
window.open('https://smartfinancial.com/auto-insurance-rates', '_blank');
return false;
}
});
我如何 (i) 检查 #fms-zip 的值是否大于 90000 且小于 96162 以提交表单,以及 (ii) 如果输入任何其他值,则将用户重定向到另一个网站?
期待您的意见:)
【问题讨论】:
-
你必须使用 && 而不是 AND
-
始终检查错误控制台!
标签: javascript jquery if-statement logical-operators