How about rendering the span that you'll place the error message in as
part of what the tag renders?  So...

<html:text property="text1" size="5"/>

...renders...

<input type="text" name="text1" size="5"><span id="text1Message"></span>

...then you can simply do as David I think it was suggested in terms of
setting innerHTML (or innerText... I seem to remember innerHTML not
actually being DOM-compliant?)  In any case, you would know the ID then
because it is generated based on the form element name.

As for the CSS issue, you would probably just add a config item for the
validation... actually, probably two, one to alter the offending element
itself and another for the error span.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Tue, April 12, 2005 9:48 pm, Niall Pemberton said:
>
> ----- Original Message -----
> From: "David Graham" <[EMAIL PROTECTED]>
> Sent: Wednesday, April 13, 2005 2:08 AM
>
>
>>
>> --- Niall Pemberton <[EMAIL PROTECTED]> wrote:
>> > ----- Original Message -----
>> > From: "Joe Germuska" <[EMAIL PROTECTED]>
>> > Sent: Tuesday, April 12, 2005 8:54 PM
>> >
>> >
>> > > This page http://www.quirksmode.org/index.html?/dom/error.html
>> > > demonstrates a more graceful way of alerting users to errors in
>> their
>> > > form than an "alert" window.  (In case you don't feel like clicking,
>> > > it uses Javascript and the DOM to add a message and change the CSS
>> > > style of the error fields.)
>> > >
>> > > Can anyone think of a good way to open up the validator javascript
>> so
>> > > that a user could plug in handling like this when desired?  Perhaps
>> > > we could define a "handleErrors(obj)" method which would receive an
>> > > array of error objects, and the default implementation would do the
>> > > same thing which currently happens now; then users could simply
>> > > redefine the function if they wanted to do something fancier.
>> >
>> > Thats one of the things I was aiming for in the validator enhancement
>> I
>> > was
>> > working on.  Part of the problem though is in letting the
>> handleErrors()
>> > method know where to put a particular fields error message and what
>> css
>> > style to set - or if valid reset.
>>
>> Maybe give handleErrors() the css id of an element that it can set the
>> innerHTML property on to write the error message?
>
> The question is where to get that id from. The JavaScript validation is
> generated from whats defined for the form in the validation.xml, with no
> reference to whats in the jsp/html except for the property name. Without
> adding additional display attributes there, then I guess the simplest
> option
> is to assume an id based on the property name with a standard
> prefix/suffix.
>
>> David
>
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to