Results 1 to 3 of 3
Thread: Validation looping question
Jan 9, 2008, 08:21 #1
- Join Date
- May 2003
- Creve Coeur, Il.
- 0 Post(s)
- 0 Thread(s)
Validation looping question
I have a form with 20 text fields. I am wanting to loop through them and validate the characters. I can write 20 routines, one for each, but I'd like to loop through them. More efficient imho.
The following sample works for the first field. But I am trying to find out how do I reference theForm.Student1 to use the "a" variable? I have tried theForm.Student + a.value and some variations, but it bombs.
I am sure it is simple. Any thoughts?
for (a=1; a<20; a++)
if (theForm.Student1.value.length > 0)
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var checkStr = theForm.Student1.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
if (j == checkOK.length)
allValid = false;