单击按钮时触发 jQueryUI datePicker,将结果发送到禁用的输入字段 [英] Trigger jQueryUI datePicker on button click, send result to disabled input field
问题描述
我一直在寻找一种方法来做到这一点,但找不到任何东西
I've been searching for a way to do this, but could not find anything
我想要一个:
禁用输入文本字段,称为#XX.此输入将存储来自 datepicker 的选定值(由于此输入已禁用,我将无法使用它来触发 datePicker)
Disabled input text field, called #XX. This input will store the selected value from datepicker (as this input is disabled I won't be able to use this to trigger the datePicker)
按钮,除了#XX.当用户单击此按钮时,将显示 datePicker.用户将选择日期,该日期将分配给禁用的输入#XX.
Button, besides #XX. When user clicks this button, datePicker will show. User will select the date, and this date will be assigned to disabled input #XX.
我想要这个,所以用户不能手动更改 - 通过输入废话 - 所选日期
I want this so user can't change manually -by typing crap- the selected date
另外,我是否应该验证是否使用 #XX.val() 输入了日期?或者有更好的方法吗?
Also, should I validate if date was entered using #XX.val()? or is there a better way?
推荐答案
<script type="text/javascript">
$(function () {
$("#datepicker").datepicker({
constrainInput: true,
showOn: 'button',
buttonText: 'Select...'
});
});
</script>
<input id="datepicker" disabled="disabled" />
这将在输入字段旁边添加一个按钮,并禁止用户在该字段中输入文本...
This will add a button next to the input field, and disable the user from entering text into the field...
这篇关于单击按钮时触发 jQueryUI datePicker,将结果发送到禁用的输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!