我開始在一些代碼工作的網頁昨天&我有麻煩工作的幾件事情。清除文本框時,任何其他單選按鈕選擇
我有4個單選按鈕,其中3個已經施加到它們&一個,其允許用戶與一個文本字段輸入自訂量旁邊值例如
[] = 3
[] = 11
[] = 32
[] = [_________] =輸入自定義金額
的問題是,如果一個用戶的按單選按鈕,選定製量並進入300 e.g,然後後來決定選擇11個預定量,他們仍然可以提交將進入這兩個值。
所以,我做的是寫一些下面這段代碼以清除該文本框,如果選擇預定義的單選按鈕。
現在的問題是,說加載頁面,用戶立即想要輸入一個自定義的金額,10次9次他們更可能按下或單擊文本框內,而不是使用下一個單選按鈕但是因爲我在啓動時禁用了它,所以我不知道解決這個用戶體驗問題的最好方法是什麼。任何人都可以幫忙嗎?這是我到目前爲止:
<input type="radio" name="am_payment" value="3" checked="checked"> <strong>64</strong>
<input type="radio" name="am_payment" value="11" checked="checked"> <strong>100</strong>
<input type="radio" name="am_payment" value="32" checked="checked"> <strong>250</strong>
<input type="radio" value="" name="am_payment"><label>Other</label>
<input type="text" name="CP_otheramount" value="" id="theamount" disabled="disabled"/>
$('input[name="am_payment"]').on('click', function() {
if ($(this).val() === '') {
$('input[name="CP_otheramount"]').val('');
$('#theamount').removeAttr("disabled");
}
else {
$('#theamount').prop("disabled", "disabled");
$('input[name="CP_otheramount"]').val('');
}
});
如果用戶點擊文本框然後單選按鈕OTHER內部需要選擇。當選擇不同的預定義值單選按鈕時,文本框需要清除(如果有任何文本已放入其中)。你究竟如何通過上述這樣做謝謝:-) – ste
我剛在的jsfiddle複製這一點,但它$(「#含量都」)專注()。似乎沒有工作? http://jsfiddle.net/dnGKM/310/ – ste
http://jsfiddle.net/dnGKM/316/你需要設置無包裝的 -
–