jqueryjquery-ui-datepicker

jquery ui date picker with default text in textbox


is there any way we can have a default text value (not some date but some sort of label, which is displayed inside textbox, but gets changed to selected date if the user selects some date.

// I want the MM/DD/YYYY to be displayed inside text box if no date is selected by user

    <input id="datePicker" value ="MM/DD/YYYY">
    $(function() { 
    $( "#datepicker" ).datepicker( )});

I tried adding a dummy input box with mm/dd/yyyy and showing and hiding the same using focus and blur methods, but its not working, properly. Is there any elegant way to achieve this? Any help is appreciated. PS: I am not using html5 and i need this thing to be working in ie 8 ,9. it should look something like this text box sample


Solution

  • You can add placeholder="MM/DD/YYYY" inside your <input>,

    <input id="datePicker" placeholder="MM/DD/YYYY">