clear a input field when it looses focus using onblur

this will cause the input field to clear when it is not in focus

HTML

<h2>This will set a default value if the value is blank</h2>
<input type="text" placeholder="Im a Placeholder" value="" onblur="if(this.value == '') { this.value = 'A Default'; }" class='mb20'>

<h2>This will clear the value when its not in focus</h2>
<input type="text" placeholder="Im a Placeholder" value="" onblur="this.value = '';" class='mb20'>
<p>i would suggest not using this option, as it will loose text input which could be quite annoying.</p>

This will set a default value if the value is blank

This will clear the value when its not in focus

i would suggest not using this option, as it will loose text input which could be quite annoying.

Other Items in javascript

No Items Found.

Add Comment
Type in a Nick Name here
 
Page Views

This page has been viewed 71 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

โค๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ•น

Random Quote
I'm a big believer in energy and the secret and that sort of thing.
Unknown