0
我想在單選按鈕更改時禁用並啓用jQueryUI datepicker字段。我使用這個代碼,第一次工作並銷燬datepicker,但當我改變單選按鈕時,它不會再建立datepicker(當點擊第一個單選按鈕時,兩個上部日期選擇器應該啓用,而兩個下來者應該完全禁用。當點擊第二個廣播按鈕,就應該禁用所有領域)如何使用jQuery禁用/啓用jQueryUI datepicker?
<tr>
<td>
<ct:selectOneRadio id="periodType"
onclick="submit();changeLableDate()"
label=""
labelKey="bond.bondPeriod"
value="#{bean.criteria.bondPeriod.periodTypeId}"
selectItems="#{bean.periodItems}"/>
</td>
<td colspan="3" style="width:65%"/>
</tr>
<tr>
<td style="width:35% !important;">
<ct:date id="fromDate2" value="#{bean.criteria.fromDate2}"
labelKey="reportCriteria.fromDate"
label="#{messages['reportCriteria.fromDate']}:"/>
</td>
<td/>
<td style="width:35% !important;">
<ct:date id="toDate2" value="#{bean.criteria.toDate2}"
labelKey="reportCriteria.toDate"
label="#{messages['reportCriteria.toDate']}:" />
</tr>
<tr>
<td style="width:35% !important;">
<ct:date id="fromDateIssue" value="#{bean.criteria.fromDateBond}"
labelKey="reportCriteria.fromDate"
label="#{messages['issue.fromDate']}:"
/>
</td>
<td/>
<td style="width:35% !important;">
<ct:date id="toDateIssue" value="#{bean.criteria.toDateBond}"
labelKey="reportCriteria.toDate"
label="#{messages['issue.toDate']}:" />
</td>
<td colspan="2" style="width:30%"/>
</tr>
<script type="text/javascript">
function changeLableDate() {
if (document.forms.reportForm["reportForm:periodType"][0].checked) {
$(".fromDateIssue").prop("disabled", true);
$(".toDateIssue").prop("disabled", true);
$(".toDate2").prop("disabled", false);
$(".fromDate2").prop("disabled", false);
$("#reportForm\\:fromDateIssue").datepicker("destroy");
$("#reportForm\\:toDateIssue").datepicker("destroy");
}
else if (document.forms.reportForm["reportForm:periodType"][1].checked) {
$("#reportForm\\:fromDate2").datepicker("destroy");
$("#reportForm\\:toDate2").datepicker("destroy");
$("#reportForm\\:fromDateIssue").datepicker("destroy");
$("#reportForm\\:toDateIssue").datepicker("destroy");
$(".fromDateIssue").prop("disabled", true);
$(".toDateIssue").prop("disabled", true);
$(".toDate2").prop("disabled", true);
$(".fromDate2").prop("disabled", true);
} }
我嘗試過,但在「日期選擇器」致殘,我不能再次啓用它 –