带有禁用字段的JQuery UI DatePicker

时间:2011-06-06 16:12:10

标签: html jquery-ui jquery-ui-datepicker

<input type="text" value="06-Jul-2011" propertyname="ChildOptionComponent.FirstRollDate" onchange="parseAndSetDt(this); " name="ChildOptionComponent_FirstRollDate" id="ChildOptionComponent_FirstRollDate" disabled="disabled" datatype="Date" class="economicTextBox hasDatepicker">

问题在于,该字段被禁用(灰色显示给用户),但您仍然可以打开日期选择器并设置日期,您无法自己手动修改日期字段。

如果禁用字段,我们如何才能使日期选择器无法打开?

2 个答案:

答案 0 :(得分:1)

要在字段上禁用datepicker,您需要使用销毁或禁用属性

DatePicker Options

示例:

someinput.disabled = true

$('select that input').datePicker('disable');

// or
$('select that input').datePicker('destroy');

答案 1 :(得分:1)

我假设你使用hasDatepicker将文本框转换为datepicker。

您可以选择/选择具有hasDatepicker类且未禁用的文本框,并将它们转换为日期选择器。

所以在你使用选择器的代码中试试这个:

$(".hasDatepicker:not(:disabled)").datepicker(..options..);