Search code examples
javascripthtmljquery-ui-datepicker

How to select date from the calender using the datevalue in the textbox


This is my html

<input type=text name="date" value=7/8/2019>

This is my date picker:

$('.datepicker').datepicker({ 
    format: 'dd/mm/yyyy', 
    autoclose: true, 
    endDate: '+0d',
    todayBtn: 'linked' 
});  

I want to select the date in the calendar using the date value in the text box


Solution

  • Your input should look like this:

    <input type="text" id="datepicker" value="7/8/2019">
    

    You need to wrap your attribute values in "" if they are not numeric.