This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Spring and the fly likes Problem in ValidationUtils Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem in ValidationUtils" Watch "Problem in ValidationUtils" New topic

Problem in ValidationUtils

Anupam Dee
Ranch Hand

Joined: Oct 18, 2010
Posts: 42

I have two fields in Person Class

I want to validate that both the names should be given by the user at the same time

ValidationUtils only gives the method to check on a particular field, how can I validate this?
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

You can do client side validation using javascript.

Put hibernate validator on your class path.

In your spring controller you can add @Valid to the model object you wish to validate. Then just use the JSR-303 annotations on your fields. Like @NotBlank or @NotNull.

Here is an example.

[How To Ask Questions][Read before you PM me]
I agree. Here's the link:
subject: Problem in ValidationUtils
jQuery in Action, 3rd edition