How to Validate Form data using using Javascript

What is Javascript

Javascript is a client-side scripting language that is validated by the browser.

There are several ways of validating form data that is submitted by the client to be inserted into the system. It’s not easy to prevent junk data that may be submitted by either robots or clients. By use of java-scripts which is a client-side scripting language meaning its executed by the browser on the client side, one can validate and prevent junk data.

For example, let say the client is required to enter email and instead he /she enters a phone number, the javascript should not allow submission of the data until the correct data is entered. There also drawbacks that come by when using Javascript. Javascript can be disabled on the browser and thus it won’t prevent the user from submitting junk data.

Here is a simple code that can be used to Validate form data.It’s upon you to add more functionalities like validating email and other forms of data

Also, See my post about

Simple PHP Registration and login form

HTML Form Code

JavaScript Code to Validate The two values submitted by the user.If the user submits nothing,the javascript code prevents  him  from going ahead with data submission