File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Unable to validate minlength Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Unable to validate minlength" Watch "Unable to validate minlength" New topic

Unable to validate minlength

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 124
In struts-validation, I am able to validate for "required" field on client side as well as server side. But if I want the field to be validated for a "minlength", I am unable to do it.

It is giving me an error, when validating for minlength:

Title Size can not be less than null characters.

Following is my .properties file:

Does anybody knows the answer for this. Thank you very much in advance.

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 124
I found the answer to this, the dtd to which the validation.xml and validation-rules.xml were pointing is a previous version. So just changed and it validates if the field is less than 3 characters.

But now I have got another error:
Now even if I enter 4 or more characters still I am getting the same error:
"Title Size can not be less than 3 characters."

Does anyone has any ideas abt this? Thanks for your time.
Ergin Er
Ranch Hand

Joined: Sep 06, 2005
Posts: 60
Are you sure you got the name of the variable right?
You define that a field needs to match 2 variables: required,minlength. Then you define a minlen?
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 124

Thanks for the reply. What you said was correct, the var:minlen is wrong, I defined it as var:minlength and its working.

But I have another problem now: I wanted to implement my own custom minlength validation as follows:

So I named it as "var:minfldlength", it is validating properly. But it was always gives the output as

"Title Size can not be less than null characters"

I do not know and I have tried all my best still the "null" is not taking the value "3" or whatever is used. But if I enter more than 3 chars, it validates properly and does not show any error.

See the code:

It is able to identify {0} from the properties file but not {1}. I do not know why.
I also tried using

still does not work.

This is the validation-rules.xml

The version of dtd I am using is validator_1_1_3.dtd

The custom Code for MinFldLength is as follows:

I do not know where the catch no matter how many ever times I try it gives my the same error:
TITLE SZE can not be less than null characters

Praise the Lord, finally just now as I was writing to this forum, I got this idea and that solved my puzzle:
In the validation-rules: I forgot to put this attribute in "validator" node:


Now I ran it and its working awesome.

Thanks for all the suggestions,
I agree. Here's the link:
subject: Unable to validate minlength