Forget whatever I was thinking, I think Jason is on the right track! Ironically, I add custom attributes all the time in numerous situations, but it frankly escaped me as a possible solution here.
All you really need beyond this is probably a new tag that renders a JS function that you can pass an object reference and it will do the setting of the style for you. So, you get: <html> <head> <html:styleSwitcher /> </head> <body> <html:form> <html:button errorStyle="itsucks" normalStyle="basicstyle" /> </html:form> </body></html> Which emits: <html> <head> <script> function styleSwitcher(obj, error) { if (error) { obj.style = obj.errorStyle; } else { obj.style = obj.normalStyle; } } </script> </head> <body> <html:form> <html:button errorStyle="itsucks" normalStyle="basicstyle" /> </html:form> </body></html> ... or similar such thing (I'm just dumping off the top of my head here). The developer has simply to call styleSwitcher(form.element, true); in the validation code to switch the style to the error style or styleSwitcher(form.element, false); to switch it back to normal. Thanks Jason, even if it doesn't go this way I can very much see this being helpful in my own work. Great call! -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Mon, April 18, 2005 2:41 pm, Jason King said: > >> >> >> Now, you raise a good point as to how the Javascript could capitalize >> on the presence of the errorStyle attribute, which normally is only >> interpreted on page load. That is, if you did any client side >> validation, you'd probably like to be able to switch the style of the >> invalid field to whatever was specified in "errorStyle" even if there >> was no error when the page loaded. This is valuable outside of the >> specifics of an Ajax situation and would also apply to any client-side >> validation. Unfortunately, I'm having trouble seeing a particularly >> clean way to do it which wouldn't involve loading down the base tags >> (because of single inheritance) and even then, I think you'd have a >> pretty contentious time getting people to agree on what the base tags >> should output. I guess maybe you could have some Application scoped >> "input tag decorator" which could be invoked by the tag if present >> while still leaving things open for customization... >> >> Joe >> >> > This one is simple. HTML ignores attributes it doesn't understand. > That means all your input boxes etc. could have an errorStyle attribute > defined (and probably a normalStyle as well) and then when the js > validation code runs it could look to see if such attributes are defined > and then copy the value of errorStyle or normalStyle as appropriate to > style when validating. In other words your emitted HTML would look like > <input type="text" name="lastname" style="basicstyle" > errorStyle="itsucks" normalStyle="basicstyle" value="King" > onChange="some_js_function(this)"> > The element renders correctly, validators that don't flip styles ignore > the extra attributes validators that use them have them. I know its > bizarre, adding atttributes to objects at run-time, but that's the world > of the DOM. > Its' been a while since I tested this, I believe if I have a text input > object in the variable oTxt to find out its "errorStyle" attribute I > have to use js like: > var es = oTxt.getAttribute("errorStyle"); // returns null if no such > attribute exists. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]