Open Source Tutorials - Open Source Training
Open source training & tutorials from experienced, passionate people
chrome icon firefox icon ie icon opera icon safari icon Sings in these Browsers
A- A A+

By A Web Design

pdf icons

Client Side Form Data Validation Using Javascript

What is data validation?

Data validation is the process which helps ensure that only clean, accurate and useful business data is stored within its business database.

When business data is captured via a form, business rules are applied to the data captured. If the business data captured passes these rules then it is stored in the database else it is rejected and an appropriate error message is displayed to the user explaining why it’s been rejected.

From a programmer’s perspective, data validation is understanding business rules and being able to apply them to business data captured in a form’s data entry field using an if condition. In this particular scenario the if condition will be written using a client side scripting language called JavaScript that is understood and executed by all modern day Browsers.

Need for data validation

  • Because you always want clean, accurate and useful data to be saved into a database
  • By projection business reports extracted based on such data will be accurate
  • Incorrect data validation can lead to data corruption or a security vulnerability.
  • You always want your system to be secured from attacks

Areas where data validation is needed

  • User Interactivity Screens And Forms:
    Any part of an application that requires a user to enter data (in a data entry screen for example) is most definitely a prime place for data validation. Human error is often a prime suspect for invalid data. Statistically, a vast majority of invalid data situations are caused by human error.
  • File Manipulation Routines:
    This entails all file related operations such writing to a file especially when the data saved is the result of user supplied information. It is good practice to install a data validation procedure at this level.

Types of data validation

Generally there are four levels of data validation in any computer application

  • Field Level Validation:

Where necessary, data entered in every field in a form can be validated at the field level itself.

  • Form level validation:

Here data validation is done only after the user clearly indicates that all fields in a form have been filled in appropriately.

  • Data saving validation:

This validation happens when data is actually being saved in database

When developing Internet driven applications there are mainly two types of validation that can be done on user data, mostly based on the physical location of this data.

  • Client-side data validation
  • Server-side data validation

Client-side data validation:

Data validation which is done using client side resources i.e. Browser based interpreters, client-side scripts.

Advantages:

  • Client side languages are very easy to code
  • Eye candy form validations can be done using client-side scripting languages eg. JavaScript

Disadvantages:

  • The biggest disadvantage of client side scripting is control lies in a clients hand i.e. this validation can be broken by simply turning off the client-side JavaScript interpreter in the Browser

Web Server-side data validation:

Data validation done using Web server resources viz. interpreter\compiler used on the Web server.

Advantages:

  • This is most secure because all control lies in the hand of server
OSV Newsletter


Receive HTML?

NOTE: To prevent subscription to the OSV newsletter, uncheck the checkbox above.
Guest Blog for OSV
Free Ebook Download
LinkShare_180x150
Artisteer - DNN Skin Generator
Tapestry Theme - A Tumblog-Style Theme for Wordpress