Bootstrap Datepicker (avoid text input or restrict manual input)

后端 未结 4 1585
旧时难觅i
旧时难觅i 2021-02-02 10:49

Here is my website: http://splash.inting.org/wp/

I currently use the Bootstrap Datepicker (range branch) for my Call Date field and it\'s been great.

Although I

相关标签:
4条回答
  • 2021-02-02 11:13

    I managed to get acceptable solution as follow:

    $(".date").datetimepicker({
        defaultDate: moment(),
        format: 'YYYY-MM-DD'
    }).end().on('keypress paste', function (e) {
        e.preventDefault();
        return false;
    });
    

    Hope it works for you too!

    0 讨论(0)
  • 2021-02-02 11:18

    Use the readonly attribute and append an add-on after the input element to trigger the datepicker after the input:

    <input type="text" name="CallDate" value="" id="CallDate" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required input-medium date date-pick" size="40" readonly>
    <span class="add-on"><i class="icon-calendar"></i></span>
    

    that should work.

    For the second problem you could use a modified version of the datepicker from here: https://github.com/eternicode/bootstrap-datepicker and use the option daysOfWeekDisabled

    0 讨论(0)
  • 2021-02-02 11:21

    Override the key events on the input control.

    <input onkeydown="return false" ... />
    
    0 讨论(0)
  • 2021-02-02 11:24

    Use onKeyDown attribute as below. It`s working for me [To Restrict the manual input in datepicker]

      <input type="text" id="signedDate" name="signedDate" 
      onkeydown="event.preventDefault()" class="form-control input-med datepicker" 
      maxlength="10" placeholder="" />
    
    0 讨论(0)
提交回复
热议问题