Hide and clear input value on click and return it back (show value) when blank

If you want to show some text or value in input tag explaining what people should type and clear when they are typing and also return text or value back if they left that blank we should add some java script code to our input tag like this:

<input type="text" value="Type anything you want" onfocus="if(this.value == 'Type anything you want') { this.value = ''; }" onblur="if(this.value=='') { this.value='Type anything you want'; }" style="color:#555; width:320px;border:1px solid #222;"/>


One comment

  1. Small business software says:

    This is what I have been searching in quite a few web pages and I ultimately identified it right here. Wonderful post. I am so impressed

Leave a Reply

Your email address will not be published. Required fields are marked *