我有下面的代碼,其中,啓用和文本框的禁止是行不通的:文本框切換JQuery的
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TEST</title>
<!-- JQuery 1.12.3 JS -->
<script src="../js/jquery-1.12.3.min.js"></script>
</head>
<body>
<table>
<tr>
<td><label class="control-label">Mode</label></td>
<td>
<label><input type="radio" name="payMode" value="cash" checked>Cash</label>
<label><input type="radio" name="payMode" value="cheque">Cheque</label>
</td>
</tr>
<tr>
<td><label>Cheque No</label></td>
<td><input type="number" name="chequeNo" pattern="^[0-9]" min="0" step="1" class="form-control" placeholder="Enter Cheque No" disabled></td>
</tr>
<tr>
<td><label>Cheque Date</label></td>
<td><input type="date" name="chequeDate" class="form-control" placeholder="Enter Cheque Date" disabled></td>
</tr>
</table>
<script>
<script>
$(':radio[name=payMode]').change(function() {
var prop = this.value == 'cash';
$('input[name=chequeNo], input[name=chequeDate]').prop({ disabled: prop, required: !prop });
});
</script>
</body>
</html>
基本上我試圖啓用基於無線點擊文本框2。如果用戶選擇支付模式作爲檢查,啓用檢查號和檢查日期文本框。如果用戶選擇現金,則禁用2個文本框。請指教
[演示](https://jsfiddle.net/rpeyrs43/)工作正常。你得到什麼錯誤? – guradio
@guradio你是對的,代碼工作正常。我有重複的腳本標籤,因此這個問題。 – Rajiv