wood burning stoves 2.0*
The moose likes Struts and the fly likes Required field usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Required field usage" Watch "Required field usage" New topic
Author

Required field usage

Shaan patil
Ranch Hand

Joined: Dec 22, 2007
Posts: 58
Hi,

I want to know will this work when I dont input any value in the birthDate text box of the form ?

Specifically what I want to know is will this be validated incase I dont input anything in birthdate field ?

<field property="birthDate"
depends="date">
<arg0 key="inputForm.birthDate" />
<var>
<var-name>datePattern</var-name>
<var-value>MM-dd-yyyy</var-value>
</var>
</field>


"You cannot change the truth but truth can change you "
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
With your definition, any empty field will not generate any validation messages. If you need the field to be filled in, change your depends value to "required,date".

- Brent
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
depends="date" this is just date validation.
required is the not null validation.

You need to add two validations for the Birthday field

1. Not null Check.
2. If not null then check for valid date.

depends = "required,date" address your issue
 
Consider Paul's rocket mass heater.
 
subject: Required field usage
 
Similar Threads
why no errors shown for password validation in struts 1.2.4
validator requiredIf checking two conds
Using masks in Validations
Validator for NOT NULL/ blanks
doubt in using validwhen