我有一个 jsFiddle展示我的问题(并让你们理顺我)。
我只是检查两个输入文本框的值并在最高价格低于最低价格时提醒用户,但他们正在向后评估!我有如果 (maxValue < minValue)...
但它对其进行评估,就好像运算符是“大于”。
我错过了什么?!?
<form id="search" action="search.php" method="post">
<label id="lblPriceMin" for="txtPriceMin">Minimum Price</label>
<input type="text" id="txtPriceMin" name="priceMin"></input>
<br />
<br />
<label id="lblPriceMax" for="txtPriceMax">Maximum Price</label>
<input type="text" id="txtPriceMax" name="priceMax"></input>
<br />
<br />
<input type="reset" id="reset" name="reset" value="Clear Form" />
</form>
这是js,
$('#txtPriceMax').focusout(function() {
var minValue = $('input#txtPriceMin').val();
var maxValue = $('input#txtPriceMax').val();
//alert ('minValue: ' + minValue + ', maxValue: ' + maxValue);
if (maxValue < minValue) {
alert ('The maximum value (' + maxValue + ') must be greater than the minimum value (' + minValue + ')!');
}
});
最佳答案
关于JavaScript if() 语句未按预期评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11870987/