|
Home -> Tutorials -> Validating Forms With Javascript
Title: Validating Forms Using Javascript
Author: Aaron Connelly
Website: CYWebmasters.com (Click for more resources!)
Email This script to your friends!
Many programmers these days forget one of the most important rules of internet programming.
NEVER - EVER trust users input!
So, in this tutorial I will show you how to use Javascript to your advantage and use
instant form validation.
First lets start this tutorial by creating a form. This form will include
First Name and Email Address fields.
Now that we have our forum designed lets go ahead and create our Javascript validation function.
We now have our skelleton function lets create a variable that will hold the form name.
Next lets validate the First name field.
To do this we will use 2 methods.
1. First lets check to see if the field is empty.
2. Make sure the user is not trying to hack the system be inputing elligal characters.
Now that we have completed our check for the First Name field, lets move on to
validating the Email Address.
I will now show the code to validate an Email Address then will place it into the above
code we just wrote.
Now lets add the above email validation code into our form validating function.
Your All Done! Enjoy!
|