Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ($) {
- // check placeholder browser support
- if (!Modernizr.input.placeholder)
- {
- // set placeholder values
- $('form').find('[placeholder]').each(function()
- {
- if ($(this).val() == '') // if field is empty
- {
- $(this).val( $(this).attr('placeholder') );
- }
- });
- // focus and blur of placeholders
- $('[placeholder]').focus(function()
- {
- if ($(this).val() == $(this).attr('placeholder'))
- {
- $(this).val('');
- $(this).removeClass('placeholder');
- }
- }).blur(function()
- {
- if ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))
- {
- $(this).val($(this).attr('placeholder'));
- $(this).addClass('placeholder');
- }
- });
- // remove placeholders on submit
- $('[placeholder]').closest('form').submit(function()
- {
- $(this).find('[placeholder]').each(function()
- {
- if ($(this).val() == $(this).attr('placeholder'))
- {
- $(this).val('');
- }
- })
- });
- }
- ......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement