I've been thinking about this myself, and the way I plan on doing it is using a variation on my usual theme of:
<logic:messagesPresent> <html:messages id="error"> <script language="jscript">alert('<bean:write name="error"/>')</script> </html:messages> </logic:messagesPresent> to using a superior jscript function to read the errors into an array which then either pops up an alert and/or dynamically changes the class of the element in question. HTH Colm -----Original Message----- From: Joao Batistella [mailto:[EMAIL PROTECTED] Sent: 18 March 2004 12:26 To: 'Struts Users Mailing List' Subject: RE: Way tho highlight error form field But, how about server side errors that I can't not validate in Javascript? I tought about something like this: <html:text property="test" styleClass="normal_class" styleClassOnError="error_class"/> So, if I return an ActionError about the property test, the style class to use would be error_class, otherwise, normal_class. I know this doesn't exist in Struts but is there something that can do something like this? Thanks -----Original Message----- From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: quinta-feira, 18 de março de 2004 10:06 To: Struts Users Mailing List Subject: Re: Way tho highlight error form field You could modify the client-side validation stuff to do this rather than just alerting. An easy way of layering this on is to define a compulsory array of fields and then loop through the form on validation. changing the borderColor style attribute when you have a match between the element name and your array. compulsary = ["name","email"]; function validate(form) { for(i = 0;i < compulsary.length;i++) { field = compulsary[i]; value = form.elements[field].value; if(value == "") { form.elements[field].style.borderColor = "#ff0000"; } } } Then you can think about having your compulsary array populated in the same way as the struts validator client-side stuff. In fact you could use the array then it defines. On 18 Mar 2004, at 10:49, Joao Batistella wrote: > Hello! > > Is there a way in Struts to highlight the HTML form field that has an > error? > I mean, changing the style class of the form field, for example. Is > there > some feature in Struts that can help me? > > Thanks, > JP --------------------------------------------------------------------- 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]