|
||
| Inside Technique : Form Validation Made Easy : Expando Properties This relatively obscure technique lets you turn HTML into a useful tool of your web application by allowing you to extend all the tags at your disposal to fit your specific needs. HTML is no longer just for formatting. Remember that anything a browser doesn't understand, it simply skips over. Below I have created a textbox for which I have defined some custom attributes. <INPUT date="MM/DD/YYYY" required name="myDate"> Obviously, older browsers can't make heads or tails of these non-standard attributes since they don't recognize it as a valid property of any HTML element. Internet Explorer 4, on the other hand, still makes these properties available to you as part of the document object model (DOM); it just doesn't know what to do with them. The next step is learning to manipulate the attributes in script. Microsoft has provided three handy methods available on each and every object in the DOM. (Keep in mind that all values declared in HTML attributes are considered strings when accessed via script.)
The beauty of expando attributes is their ability to store any kind of data format. You can go far beyond using these special attributes to store text. Any non-string value must be defined in script. Next we'll learn how to create pseudo-events with this technique. Page 1:Form Validation Made Easy © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |