Skip to main content

Posts

Showing posts from 2022

Clear Default Text using JAVASCRIPT

Many web designers like to add some default text to form inputs like text boxes, to signify what the user should type into the box. When the user clicks the input, this default is removed so they can begin typing. This can be a nice usability improvement when used correctly. Below you'll find a nice, clean way to approach it, that requires minimal work on your part to get it working. The HTML On this page we're going to work through an example of a single text box that comes with some default text. When the user clicks on the box, the default text is wiped away so that they can begin typing. If they click away from the box, without typing anything in, we will add the default text back so that they don't forget what was meant to be typed. Check it out below: Enter a date: Creating this text box is easy, we simply add the default text through the input's valueattribute, like so: Enter a date: <input type="text" name=...