Clear input field

Posted on

in

,

This code clears a text input field if it is the default text specified in the js. This can be used for things like search boxes or text fields in a form.

To use it, add in the js:

clearInput("inputClass","defaultText");

where “inputClass” is the class of the text field and “defaultText” is the default text that will clear if that’s what’s in the input field when focused.

View the demo

Download the demo

Leave a Reply

Your email address will not be published. Required fields are marked *

About me

Mark Wong is a front end developer with 10+ years experience. Most of his knowledge of HTML5, CSS and Js is self taught.

Calendar

March 2025
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
31