Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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