--- Adam Hardy <[EMAIL PROTECTED]> wrote:
> I started using struts validator. I just copied a bunch of stuff from 
> the struts example and started using that, and found that the minlength 
> validation actually returns true when the text field is blank.
> 
> This was my first attempt and I was trying to make sure I had got the 
> validator plug-in functioning correctly, so I actually spent a few hours
> 
> hunting down the reason why my blank field was passing validation even 
> though the minlength had been set to 1.
> 
> I discovered in the source code that this is normal behaviour - surely 
> that can't be the case? I would expect a blank field to fail validation 
> for minimum length. Or is this actually the case for reasons I'm not 
> aware of?

This is actually a good thing :-).  Minlength will only fail if there is
some text in the control and it's less than the minimum length.  If you
want it to fail with no data you need to use the required validation.  By
separating these validations you can make a field optional and if the user
fills it in, it has to be more than minlength characters.

David


> 
> Thanks
> Adam
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to