I have a input field with id 'datepicker'
While validating, if date mentioned is not valid
I am empty the field and adding the placeholder
if(validationfails)
{
$("#datepicker").val('');
$("#datepicker").attr('placeholder',"MM/DD/YYYY")
}
Now the input field doesn't have anything, but the placeholder is missing.
if I focus the input field and press "backspace"
The place holder "MM/DD/YYYY" appears
Try to change your code to this one. Enclose your IDs in quotes.