我有一個像下面的Javascript比較不工作
function check()
{
var amount = document.getElementById('pamount').value;
var quantity = document.getElementById('qty').value;
var pmin = document.getElementById('pmin').value;
var pmax = document.getElementById('pmax').value;
var stock = document.getElementById('stocks').value;
if (amount > pmax) {
alert('Price should not be more than maximum price');
return false;
}
if (amount < pmin) {
alert('Price should not be less than minimum price');
return false;
}
if (quantity > stock) {
alert('Please enter quantity no more than maximum');
return false;
}
if (quantity < 1) {
alert('Please enter valid quantity');
return false;
}
}
這裏是HTML字段
<input type="text" value="" data-toggle="tooltip" data-placement="top" class="form-control small qty_box" id="qty" name="qty">
<input style="width:90px; float:left" type="text" value="" class="form-control small" id="pmin" name="min">
<input style="width:90px; float:left" type="text" class="form-control small" id="pmax" name="max">
但它總是返回false在JavaScript的條件。當我輸入較少的金額時,它會發出警報。我嘗試了警報量和pmax。它獲得實際價值。可是,我錯這個比較 我給量爲75和p最大爲100
請顯示完整的代碼。 – ram
@ user3280126但我嘗試了警報值。它僅顯示實際值 –
您獲得了哪些警報? 'quantity','stock'和'pmin'怎麼樣? – alalp