Whitmire, Tracy Carroll schrieb:
Hi,
I'm using t:inputCalendar and have a question I'm sure someone has
already addressed. But a google search was futile.
If a user decides to enter the input in manually …. What's the best
way to validate this input?
I have a user who loves to enter the date as MM/dd/YY ignoring the
help text
But the expected is MM/dd/yyyy
So when he enters 12/01/06 ….
It gets entered into the database as Dec, 01, 0006
Thanks for your help,
tc
I use the following code to do that (just write a validator like u are
used to it in jsf)
<t:inputCalendar id="birthDate"
value="#{member.birthDate}"
renderAsPopup="true"
popupTodayString="#{messages['popup_today_string']}"
popupWeekString="#{messages['popup_week_string']}"
popupDateFormat="dd.MM.yyyy"
helpText="DD.MM.YYYY"
required="true"
validator="#{validators.birthDateValidator.validate}"/>
where validators is a bean and returns a new Validator Object (u can
play around a bit and register the validator in faces-config.xml but i
choosed this approach).
Just write a validator like in jsf.
public class BirthDateValidator implements Validator {
public void validate(FacesContext fc, UIComponent uic, Object o) {
//do validation here
}
}
thats it, i was suprised it works like i "expected"