功能:條件檢查斷續進行
的用戶在receipt_details頁面輸入自己的開支,並根據他們是否已經檢查一個複選框,最小的支出條件將differ.If他們已經檢查中,最低支出是120美元,否則就是150美元。
有2個收據細節的TextField在頁面因此,這些將是下面的檢查條件:
1)如果(receipt_field_1超過120 OR receipt_field_2超過120 OR receipt_field_1的總和& receipt_field_2是超過120) - >用戶可以提交併導航到下一頁。否則,一個錯誤味精將出現
2.)如(receipt_field_1超過150 OR receipt_field_2超過150 OR receipt_field_1 & receipt_field_2的總和超過150) - >用戶可以提交併導航到下一頁。否則,一個錯誤味精會出現
問題:
在這一點上,檢驗條件是正確和一致的以下行爲:
1)當任receipt_field_1或receipt_field_2超過規定值(120/150),則允許用戶提交併導航到下一頁其他頁面,錯誤消息
我遇到的問題是最終檢查SUM條件不一致:意思是,有時它能夠解碼和計算總和是否小於或大於所述值(120/150),有時它是無法解碼和計算總和是否小於或大於
因此,我不確定爲什麼這樣做是爲了檢查SUM條件如此不一致。請幫忙。
//AmexCard User
if ($('#AmaxCardField').is(':checked')) {
//Check that the input value field is $120 or more else, inform that minimum spending is 120
if (($("#ReceiptField_1").val() >= 120) || ($("#ReceiptField_2").val() >= 120) || ((($("#ReceiptField_1").val()) + ($("#ReceiptField_2").val())) >= 120)) {
//Condition Passed
console.log("Amex user and spent more than 120");
alert("You are an AMEX member and spent more than 120");
} else {
//inform that minimum spending is 120
alert("You need to spend more than 120");
}
} else if ((!$('#AmaxCardField:checked').length)) {
//Check that the input value field is SGD$150 or more else, inform that minimum spending is SGD150
if (($("#ReceiptField_1").val() >= 150) || ($("#ReceiptField_2").val() >= 150) || ((($("#ReceiptField_1").val()) + ($("#ReceiptField_2").val())) >= 150)) {
//Condition Passed
console.log("Non-Amex user and spent more than SGD150");
alert("You are an AMEX member and spent more than 150");
} else {
//inform that minimum spending is SGD150
alert("You need to spend more than 120");
}
}
<form>
<!-- DropDown Menu to choose Participating Outlet -->
<select id="dropDownShops_1">
<option value="" selected disabled>Please Select Shops ...</option>
</select>
<input type="text" id="ReceiptField_1" style="z-index=10; position:absolute; top:390px; left:858px; height:58px; width:265px; outline:0; border: 0; font-size:25px; font-family:'Gothic'; color:#765725; background: transparent;" autofocus>
<select id="dropDownShops_2">
<option value="" selected disabled>Please Select Shops ...</option>
</select>
<input type="text" id="ReceiptField_2" style="z-index=10; position:absolute; top:585px; left:858px; height:58px; width:265px; outline:0; border: 0; font-size:25px; font-family:'Gothic'; color:#765725; background: transparent;">
<input type="checkbox" id="AmaxCardField" style="z-index=10; position:absolute; top:690px; left:420px; height:30px; width:30px; outline=0; border: 0; background: transparent;">
</form>
PLunker:https://plnkr.co/edit/obkHLkBC7toFo4t30Sfd?p=catalogue
非常感謝!!詳細的解釋 – Luke