How to remove placeholder text from input field when click on input field (onfocus and onblur)

In your input field just add two simple javascript code to clear any input field. The codes are following below:


onfocus="this.placeholder=''" (Its remove placeholder text)

And

onblur="this.placeholder='User Name'" (Its Add Placeholder text)

Just Add two above code to your input field to clear and add placeholder text.

You can see the Example here:

<input type="text" onblur="this.placeholder='User Name'" onfocus="this.placeholder=''" placeholder="User Name" name="name">

And

<input type="password" onblur="this.placeholder='Password'" onfocus="this.placeholder=''" placeholder="Password" name="name">

To view full html file click the image:

onfocus-onblur learn html css




Latest
First


How to remove placeholder text from input field when click on input field (onfocus and onblur)

In your input field just add two simple javascript code to clear any input field. The codes are following below: onfocus="this.place...