0

I have input field with id = datepicker

 validationfails = true;

 if(validationfails)
 {
     $('#datepicker').val('');
     $('#datepicker').attr('placeholder','mm/dd/yyyy');
 }

I want to show the placeholder, if validation fails.

But the placeholder does not appear. When i press the backspace in the input field, it appears.

how to fix this.?

Karthik Amar
  • 217
  • 5
  • 17

1 Answers1

3

Try:

$('#datepicker').attr('placeholder','mm/dd/yyyy').focus().blur();
Rajiv007
  • 1,126
  • 7
  • 13