Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear a textbox using javascript

Tags:

javascript

I have a

<input type="text" value="A new value"> 

I need a javascript method to clear the value of the textbox when the focus is on the textbox.

How can this be achieved?

like image 595
kalls Avatar asked Nov 09 '10 16:11

kalls


People also ask

How do you clear a textbox in HTML?

To clear all the input in an HTML form, use the <input> tag with the type attribute as reset.


1 Answers

just get element using

   function name()    {      document.getElementById('elementid').value = "";    } 

you can call this function on onfocus event of textbox and clear the value

like image 97
zish Avatar answered Sep 22 '22 13:09

zish