Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add Placeholder Support
- *
- * This adds backwards compatibility for HTML5 placeholder attributes
- * @since 0.0.1
- */
- function addPlHolderSupport() {
- var plhName = 'placeholder';
- var inpt;
- if(Modernizr && !Modernizr.input.placeholder)
- {
- $('['+plhName+']').bind({
- focus : function(){
- inpt = $(this);
- if(inpt.val() == inpt.attr(plhName)) {
- inpt.val('');
- inpt.removeClass(plhName);
- }
- },
- blur : function(){
- inpt = $(this);
- if(inpt.val() == '' || inpt.val() == inpt.attr(plhName))
- {
- inpt.addClass(plhName);
- inpt.val(inpt.attr(plhName));
- }
- }
- }).blur();
- $('['+plhName+']').parents('form').bind('submit', function(){
- $(this).find('['+plhName+']').each(function(){
- inpt = $(this);
- if(inpt.val() == inpt.attr(plhName)){
- inpt.val('');
- }
- });
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement