JavaScript form validation

J

JohnH

I need to validate some entries on a FP web form:

1. If a number is less than 10 digits long, then it is
padded with leading zeros, so 100 would become
0000000100

2. If a number begins with a A, then it needs to have
6 digits after it. If a single digit is entered, then
it needs to be padded with zeros, so A1 would be
A000001

3. If a number starts off with 100, then it needs to be
13 digits long

Please help with some JavaScripint please. Some links
would be useful.

Thanks.

John
 
J

Jim Buyens

Do all these rules apply to the same field, or to
different fields?

What about the entry "100"? Should it be 0000000100 (10
digits) or 1000000000000 (13 digits)? Same for 1000,
10000, ...

What are you going to do with the corrected values once
the JavaScript computes them?

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
Top