This may help:
http://jroller.com/page/raible?anchor=validating_dates_with_commons_validator
Matt
On 7/10/07, Msarda <[EMAIL PROTECTED]> wrote:
Hi All,
I am trying to validate date field in validation.xml file but getting error
message that the date entered is not a date.
I have priorityDate field in model object with type java.util.Date.
I have used customDateBinder in my controller as..
public void initBinder(HttpServletRequest request, ServletRequestDataBinder
binder) {
String dateFormat =
getMessageSourceAccessor().getMessage("format.date",
"dd/MM/yyyy");
SimpleDateFormat df = new SimpleDateFormat(dateFormat);
df.setLenient(true);
binder.registerCustomEditor(java.util.Date.class, new
CustomDateEditor(
df, true));
}
In validation.xml file i have ---
<field property="priorityDate" depends="date">
<arg0 key="engagementform.priorityDate"/>
</field>
I tried with..
<field property="priorityDate"
depends="mask">
<msg
name="mask"
key="errors.date"/>
<arg0 key="engagementform.priorityDate"/>
<var>
<var-name>mask</var-name>
<var-value>${dateformat}</var-value>
</var>
</field>
where dateformat is
<constant>
<constant-name>dateformat</constant-name>
<constant-value>^((0[1-9]|[1-2][0-9]|30|31)[/](0[1-9]|11|12)[/](19|20)\d\d)$</constant-value>
</constant>
I also tried with...
<field property="priorityDate" depends="date">
<arg0 key="engagementform.priorityDate"/>
<var>
<var-name>datePattern</var-name>
<var-value>dd/MM/yyyy</var-value>
</var>
</field>
But in all the cases i was getting the same problem. :(
Even if i was entering the date in correct format,i was getting errro
message that priority date is not date. :(
Can anybody help in thi sissue please.
Thanks in advance.
--
View this message in context:
http://www.nabble.com/Problem-with-date-validation-tf4054363s2369.html#a11516397
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
http://raibledesigns.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]