QUOTE(masterio @ Sep 9 2006, 08:54 PM)

does anyone know how chek alot of fields with javascript? I'm newbie in javascript, how to pass fieldname to an array? should we use getElementById or shomething?
Yes you can use the method getElementById()
Why getElementById() ? When the web document is generated, there are so many methods which can be used belonging to the document object. Since you want to use an array to control validation of all your fields, you can opt to use a String array whereby you input all the names of your fields like txtName, or whatever you call your textboxes.
And another array whereby you store your error messages.
Using a for loop to loop through all the values in the String array.
CODE
(for int i=0; i<aryFieldName.length; i++) {
/*
This is where you can pass in your String array values into something like this
*/
var objControl;
objControl = window.document.getElementById(aryFieldName[i]);
intValue = objControl.value;
if (intValue = "") {
alert(aryErrorMsg[i]);
}
}
This is how I feel things should be done, feel free to try it. If you have a better solution do propose it
Reply