Validate Form Input on the Client Side

Validate Form Input on the Client Side

If you are developing Web pages that provide HTML forms to the user, then you may notice that many times invalid data gets submitted. To reduce such invalid input, you can easily implement some basic validation at the client side. This way you will save some extra hits to the Web server. For example, if your Web page contains a login dialog, then you can easily check for the minimum length of the login or certain invalid characters in the login string.

Here is a sample HTML page that contains a login form that validates at the client side for the minimum number of characters in a login and password string. From the “ONCLICK()” event of the OK button, the Validate() method is called, which then calls the submit method of the form if the login information is correct.

 Form Validation Demo


Share the Post: