Making my own attibutes for HTML Tags

Giganews Newsgroups
Subject: Making my own attibutes for HTML Tags
Posted by:  RIck Measham (ric…
Date: Tue, 16 Sep 2003

Is there some way to access an attribute to a tag that I've made up? Eg:
        <INPUT type="text" name="phone" size=12 validate="area_phone_au">

I can get the type using:

But I don't seem to be able to access the 'validate' attribute:

Anyone know if there's a way? If there's not, is there some other simple way
to specify validation information for a field? I could do something like:

        <INPUT type="text" name="phone" size=12>
        <SCRIPT> add_validation(, "area_phone_au") </SCRIPT>

        <INPUT type="text" name="state" size=4>
        <SCRIPT> add_validation(document.formname.state, "format:AAA?") </SCRIPT>

The 'validate' function would then store the reference to the field and the
validation information. On submit, we validate all the fields by searching
all the references to see if they're in the form we want. (Have to work
that one out too!)

I'd prefer not to have to add script elements to do the validation. I'd
prefer to be able to store it in an attibute to the field. Of course I
could add it to an eventhandler for the field such as:
        <INPUT type="text" name="state" size=4 onFocus="add_validation(this,

But that's still messier than I'd like it. Of course, all JS cases,
add_validation would have to check to see if it already knew about the

Thanks for your help.