Clearing a form field in Javascript upon click

Clearing a form field in Javascript upon click

Do reset on form . link

document.getElementById(frm).reset();

or Set the value of textbox like this

 document.getElementById(output).value = ;

Why not just use the built-in reset type?

<input type=reset value=C/>

This would have to be inside the <form>.

Clearing a form field in Javascript upon click

For resetting form input fields, this worked for me:

 document.getElementById(elementId).value = ;

If you are trying to reset elements on the page that isnt a form, this worked for me:

 document.getElementById(elementId).innerHTML = ;

Leave a Reply

Your email address will not be published.