SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Resource

Easy Cross-Browser Form Validation Using Regular Expressions

Categories...
Language
JavaScript
Product
IE4, IE5, NS4
Task
Cross-Browser DHTML, Form Enhancement, Utilities
Technology
ECMA-262

Sponsored Links
Developer's Paradise : Inside Technique :
Easy Cross-Browser Form Validation Using Regular Expressions
Submission by kgayda

Go to the resource:
Easy Cross-Browser Form Validation Using Regular Expressions

Add to Assistant

Short Description
A tutorial on the basics of using cross-browser regular expressions to validate and format input.

Long Description
Karen shows you how JavaScript 1.2 regular expressions can be used to perform cross-browser input validation and formatting. See how to use the regular expression object to validate and format numbers, zip codes, phone numbers, and more.

Author
Karen Gayda
Date/ Version
4/17/2000
Submission URL
http://www.SiteExperts.com/tips/functions/ts23/page1.asp
Submission Date
Apr 17,2000
Last Update
Oct 21,2003
 

Discussion and Rate this Resource
Overall Rating: 4.3

ilude on Dec 22, 2005 at 5:53:30 PMNo Rating
Great, works like a charm! Thanks again!
kgayda on Dec 21, 2005 at 4:03:31 PMNo Rating
Oh yeah, thanks for the kind words about the article.
kgayda on Dec 21, 2005 at 4:02:40 PMNo Rating

Declare your form something like this:

<form name="frmMyForm" onSubmit="return Validate(this)">

Then your Validate() function should return true only if all form fields pass the validation test.  Otherwise return false from the Validate function.

You can do the failed validation handling in one of two ways.  Return false on the first failure and focus on the failed field after notifying the user of the error or build a string listing the fields that fail and why before notifying the user and returning false.

ilude on Dec 20, 2005 at 5:49:59 PMRating: 5
I think this article is amazing and easy, which is all the more reason I feel like a complete idiot at the moment.

I can copy and paste code exact as in your examples, however, if the validation fails it is not restricting the from from being processed. I have used an onClick event for the button, should I being using the onSubmit action for the form?

Thanks so much! Again, this article is GREAT!
raphpell on Jul 14, 2005 at 4:42:20 AMRating: 5
Très bon article / Very useful Article.
Thanks !!!

More Ratings/ Comments


To rate and comment on a resource, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password

Copyright © 1997-2008 InsideDHTML.com, LLC. All rights reserved.