I'm using Struts2 validation on a web form. In the case that a field is suppose to be an integer or Date, the <s:fielderror>
message I receive is a generic Invalid field value for field "[fieldname]"
Naturally, I want to customize this for the user.
Here's an example validation:
<field name="spouseDOB">
<field-validator type="date">
<message>"Spouse Date of Birth" is invalid.</message>
</field-validator>
<field-validator type="date">
<param name="min">01/01/1900</param>
<message>"Spouse Date of Birth" must be after 1900 AD.</message>
</field-validator>
</field>
The message "Spouse Date of Birth" is invalid.
never appears, for any invalid date that I have tried. The output is the generic Invalid field value for field spouseDOB
spouseDOB
is a java.util.Date
object in the action class. It is set by a <s:textfield>
in the JSP.