This will place a green border around the input box.
The full code looks like this: The same approach can be used to validate the email address.
Finally, notice that instead of using "text" as the input type for the email and url fields, we use "email" and "url".
This will buy us free validation from browsers that support HTML5 even if Java Script is turned off.
Clicking on the label will move the mouse cursor to the input with the id specified in the for attribute.
In this way, client side form validation can vastly improve the user experience.
If you are using a My SQL database, this is called My SQL Injection.
To avoid this problem, you must validate form submissions using your server.
You cannot rely on Java Script to avoid this security problem. You can also download this demo and check out the source as we go through this tutorial.
Download Demo Source Our form contains two types of validation. Valid inputs will turn green while invalid inputs will turn red.
These error message will only be displayed after the form is submitted.