Created
December 19, 2012 02:15
Revisions
-
stephensprinkle revised this gist
Dec 19, 2012 . 1 changed file with 25 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,36 +2,36 @@ Note: for each input you have to set both a `placeholder` and a `value`. Example: <input name="home_phone" type="text" value="Phone Number" placeholder="Phone Number" /> Function: function defaultInputValues(){ //Handle Cross Browser Default Input Values var placeholderSupported = !!( 'placeholder' in document.createElement('input') ); if (placeholderSupported === true){ $('input:not([type="submit"])').val(''); } else{ $("input") .focus(function() { if (this.value === this.defaultValue) { this.value = ''; } }) .blur(function() { if (this.value === '') { this.value = this.defaultValue; } }); }; $("select").bind("focus", function () { $(this).children('option[value="defaultValue"]').remove(); $(this).removeClass('default-value'); }); $("select").addClass('default-value'); } -
stephensprinkle revised this gist
Dec 19, 2012 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,13 @@ Note: for each input you have to set both a `placeholder` and a `value`. Example: <input name="home_phone" type="text" value="Phone Number" placeholder="Phone Number" /> Function: function defaultInputValues(){ //Handle Cross Browser Default Input Values var placeholderSupported = !!( 'placeholder' in document.createElement('input') ); -
stephensprinkle created this gist
Dec 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ function defaultInputValues(){ //Handle Cross Browser Default Input Values var placeholderSupported = !!( 'placeholder' in document.createElement('input') ); if (placeholderSupported === true){ $('input:not([type="submit"])').val(''); } else{ $("input") .focus(function() { if (this.value === this.defaultValue) { this.value = ''; } }) .blur(function() { if (this.value === '') { this.value = this.defaultValue; } }); }; $("select").bind("focus", function () { $(this).children('option[value="defaultValue"]').remove(); $(this).removeClass('default-value'); }); $("select").addClass('default-value'); }