Delete default input value on click

lapkričio 18th, 2011

I hate this task: „Delete default value of an input text on click„. Many times i use code like this

<input type="text" value="email@email.com" name="email"
onblur="if (this.value == '') {this.value = 'email@email.com';}"
onfocus="if (this.value == 'email@email.com') {this.value = '';}" />

Forget about this! I would recommend you try HTML5 solution below which uses the placeholder attribut.

<input name="Email" type="text" value="" placeholder="email@email.com" />

Be Sociable, Share!

One Response to “Delete default input value on click”

  1. 1 Makendra
    gruodžio 1st, 2011 at 12:49

    A bit suriprsed it seems to simple and yet useful.

Leave a Reply