Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevShahidul/5638d6468488ceeb085ef40fc9f9222c to your computer and use it in GitHub Desktop.
Save DevShahidul/5638d6468488ceeb085ef40fc9f9222c to your computer and use it in GitHub Desktop.
This function for input active state on focus with value added and value removed state.
// Begin input common focus and blur for value.
$('input:text,input:password,textarea').focus(function(){
if(this.value==this.defaultValue){
this.value='';
}
})
$('input:text,input:password,textarea').blur(function(){
if(!this.value){this.value=this.defaultValue;}
if(this.value==this.defaultValue){
$(this).removeClass('value-added')
}
else{
$(this).addClass('value-added')
}
})
// Ends input common focus and blur for value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment