I wanted to change the background color of fields
that have a validation error to red.
Can anyone help me with this?. How to or what tags to use to change the background color of that text field.
I am using the struts validator plugin to do the validations.
-
VALIDATION ERRORS IN STRUTS (3 messages)
- Posted by: Kiran Gundurao
- Posted on: February 07 2005 10:14 EST
Threaded Messages (3)
- RE: VALIDATION ERRORS IN STRUTS by Prasad Javdekar on February 08 2005 09:08 EST
- Thanks, by Kiran Gundurao on February 08 2005 21:50 EST
- Almost the soluttion by rogel garcia on February 27 2005 08:33 EST
-
RE: VALIDATION ERRORS IN STRUTS[ Go to top ]
- Posted by: Prasad Javdekar
- Posted on: February 08 2005 09:08 EST
- in response to Kiran Gundurao
I wanted to change the background color of fieldsthat have a validation error to red.Can anyone help me with this?. How to or what tags to use to change the background color of that text field. I am using the struts validator plugin to do the validations.
Hi Kiran,
I've not yet used Validator framework in Struts, but see if this helps:
Whenever there are validation errors,the ActionErrors is non-empty. To display the error messages on the JSP, you might be using this ActionErrors object, something like -
<logic:messagesPresent> tag. The same tag you may use when rendering the form controls and if messages are present, change the styleClass of the control e.g.
<logic:messagesPresent message="true" property="ErrorMsg">
<html:text property="firstName" styleClass="errorStyle">
</logic:messagesPresent>
<logic:messagesNotPresent message="true" property="ErrorMsg">
<html:text property="firstName" styleClass="normalStyle">
</logic:messagesNotPresent>
Hope that helps,
regards,
-Prasad -
Thanks,[ Go to top ]
- Posted by: Kiran Gundurao
- Posted on: February 08 2005 21:50 EST
- in response to Prasad Javdekar
Prasad,
Thanks for your kind reply. I am using these tags and it works. I was wondering if there was any other efficient technique to identify the errored fields.
Anyways thanks once again.
Kiran -
Almost the soluttion[ Go to top ]
- Posted by: rogel garcia
- Posted on: February 27 2005 08:33 EST
- in response to Prasad Javdekar
http://www.vleite.net/rogel/javascriptValidation.htm
This article shows how to do client side validation on indexed properties for struts. This is not what you want, but it has a zip file that has something intereting for you. In this zip file there are a lot of changed javascript validation files. These files do not handle the error fields the same way the original files did, it send references for the wrong fields to a new funtion called invalidFields(form, fields, msgs, validationName). The new function recieves references to all the fields that have errors. With that references will can set the color to red.
fields[i].style.backgroundColor = '#FF0000';
http://www.vleite.net/rogel/javascriptValidation.htm
Download the zip file, replace the necessary files and change the invalidFields function to do what you want. This function is in the file validateUtilities.js