What\'s the best way to have a text input field that displays instructions of what to enter in that field in gray. When you focus on that input field, the gray instruction text
placeholder code - name
name of the variable is,
var name=$("#con-name");
var nameval="Enter your name";
name.val(nameval);
name.focus(function(){
if (this.value == nameval ) {
this.value = '';
};
}).blur(function(){
if (this.value == '') {
this.value = nameval;
};
});
//submit to clear code
$("#sub_con_page").click(function() {
if(name.val()==nameval) {
name.val("");
}
});
DEMO LINK