I have a date of birth field:
<input type="text" id="dob" name="dob" placeholder="Date of Birth" />
I use the jQuery plugin (Charl van Niekerk placeholder text) to make sure older browsers see placeholder text. All is good so far.
When I am clicked on the date of birth field, I want to switch from the placeholder text to the input mask. For this, I use another plugin (http://digitalbush.com/projects/masked-input-plugin/).
However, I only want to activate the onfocus input mask and remove its onblur, otherwise it stops showing placeholder text.
I need something like:
$(document).ready(function() {
$('#dob').focus(function() {
$.mask.definitions['~']='[+-]';
$('#dob').mask('99/99/9999');
});
$('#dob').blur(function() {
});
});
This code is currently not working. Any ideas?
source
share