开发者

JQuery UI DatePicker with disabled field

开发者 https://www.devze.com 2023-03-10 14:05 出处:网络
<input type=\"text\" value=\"06-Jul-2011\" propertyname=\"ChildOptionComponent.FirstRollDate\" onchange=\"parseAndSetDt(this); \" name=\"ChildOptionComponent_FirstRollDate\" id=\"ChildOptionCompone
<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">

Problem here is, the field is disabled (greyed out to the user), but you can still open the Date Picker and set the date, you just 开发者_如何学运维can't manually modify the date field yourself.

How can we make the Date Picker unable to open when the field is disabled?


To disable datepicker on a field you need to use the destroy or disable properties

DatePicker Options

Example:

someinput.disabled = true

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

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


I assume you are using hasDatepicker to convert the text boxes to datepicker.

You can just pick/select the textboxes that have the hasDatepicker class and are not disabled and them convert them to date pickers.

So in the code where you are using the selector try this:

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

精彩评论

暂无评论...
验证码 换一张
取 消