Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validate field

 
Tmmet Johnson
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way in Struts to validate a field , only, if it has a value?
I have a Email id field which I want to validate only if the user enters a value in that field,if not, I don't want it to validate.
Could anyone let me know how this can be done?
Thanks,
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the validation framework all validations only run when a value is entered by default (other than the "required" validation of course). You do not need to do anything special.

If you are not using the validation framework you can simply skip validation when a field's value is null or empty string.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic