Web tier: servlets, JSP, Web frameworks: VALIDATION ERRORS IN STRUTS
I wanted to change the background color of fields
- Posted by: Kiran Gundurao
- Posted on: February 07 2005 10:14 EST
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.
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.
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:messagesNotPresent message="true" property="ErrorMsg">
<html:text property="firstName" styleClass="normalStyle">
Hope that helps,
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.
fields[i].style.backgroundColor = '#FF0000';
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