Hi guys,
I'm using Spring MVC, and JSR-303 validation.

I have the following field defined in a class:
Code:
@NotEmpty
@Length(min = 3, max = 20)
@Pattern(regexp = "[a-z]+")
private String username;
I'm using <form:error> tag to display error messages. When I enter nothing into the field, I will receive 3 error messages. I want it to show only one message at a time. When I enter nothing, there's no point of validating the length of the string or special character.

I tried to use Validation Group but it didn't work the way I wanted. If I have another field firstName which also have 'NotEmpty' constraint, if I leave firstName blank and fill in some special chars in username, it won't display error for username, because 'NotEmpty' hasn't been fulfilled by firstName yet.

Has any one experienced similar issues? and is there any solutions about it?
Thanks a lot

p.s. I know I can probably just rely on only one regular expression constraint to solve my problem, but I don't want to do that. The reason is I want to display different error messages for the 3 different constraints.