• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to validate minlength

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Lk.
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ergin,

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:

jsFunctionName="org.apache.commons.validator.javascript.validateMinLength"

Now I ran it and its working awesome.

Thanks for all the suggestions,
Lk.
 
please buy my thing and then I'll have more money:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic