View Full Version : Strange problem with validation

10-24-2006, 10:02 PM
I was given a project this week to find a way to validate a form that uses utf-8 number system to name alot of the obj in the form. From what i understand we cant change anything on the database so we are stuck using those numbers. But Javascript wont let me use a name with a digit in the beginning.

Does anyone know another way to validate a form instead of using ID or name?

I understand that there is something called validation by element but im not sure i understand what that is.

Thank you for reading through.

10-24-2006, 10:22 PM
Are you asking how to select a form element without using an ID? You could do it based on the elementís position in the page structure; for example, document.getElementsByTagName("input")[4] would select the fifth occurance of an input element in the document.

10-24-2006, 10:56 PM
so say i have 3 input boxes and then 2 drop down objects would that be then be document.getElementsByTagName("input")[4] or would just the input boxes be in the array??

Im sorry i cant seem to get out what i mean clearly.

but thanks for the help.

10-25-2006, 12:37 AM
getElementsByTagName() is an array of all elements in the document matching the provided name; the elements are in the array in the order in which they appear the document. getElementsbyTagName("input") would not include drop-down objects; you would need getElementsByTagName("select") for that.