Trigger jQueryUI datePicker on button click, send result to disabled input field

前端 未结 3 1992
醉话见心
醉话见心 2020-12-09 20:08

I\'ve been searching for a way to do this, but could not find anything

I want to have a:

  • Disabled input text field, called #XX. This input will

相关标签:
3条回答
  • 2020-12-09 20:46

    You can show a datepicker that has been previously attached to an input element using the "show" method.

    $('#myButton').click(function () {
        $('#myField').datepicker("show");
    });
    
    0 讨论(0)
  • 2020-12-09 20:53
    <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...

    0 讨论(0)
  • 2020-12-09 20:55

    Might be to late but I just did this

    $("#firstDate").datepicker({
        onSelect: function () {
            myfunc();
        }
    }); 
    
    $("#secondDate").datepicker({
        showOn: ''
    }); 
    
    function myfunc(){
        var fDate = $('#firstDate');
        var sDate = $('#secondDate');
        sDate.val(fDate.val());
    }
    

    It doesn't show the datepicker clicking the input and doesn't display the button to show the datepicker. Disabled doesn't work in my case because I need to extract the value from that input field.

    0 讨论(0)
提交回复
热议问题