[thelist] Identifying HTML Elements with javascript

ben morrison morrison.ben at gmail.com
Fri Jul 7 11:32:49 CDT 2006


On 7/7/06, Ben Glassman <bglassman at gmail.com> wrote:
> Hi all,
>
> I'm working on a javascript form validation script and I am trying to
> cycle through an array of html objects (in this case they are form
> elements, inputs, selects, etc.) and I want to know what the best way
> to get javascript to figure out exactly what type of object it is
> dealing with so I can execute a different function to validate a text
> field, select, radio, etc.
>
> Currently I've got it to work (for checking if its a select object)
> with the following if statement
>
> if (elem == "[object HTMLSelectElement]") {
>
> }

Christian has written a good article on enhancing forms, which should
be a good primer for you.

http://www.onlinetools.org/articles/unobtrusivejavascript/chapter5.html

It maybe worth you following the whole unobtrusive tutorial:

http://www.onlinetools.org/articles/unobtrusivejavascript/index.html


Ben



More information about the thelist mailing list