• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Validator framework

 
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to Validator framework.I am trying to validate a form on the browser itself.But the validation is not happening.Please find the code below.



this is my JSP form page which i want to validate

my Validation.xml

<formset>

<!-- An example form -->
<form name="firstForm">
<field
property="name"
depends="required">
<arg key="firstForm.name"/>
</field>
<field
property="password"
depends="required,mask">
<arg key="firstForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>

</formset>
[/code]

and i have put the subsequent entries in the struts-config.xml also.
I think onsubmit javascript event handling is not happening
please help

Thanks in advance
Saurav
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try changing validatefirstForm(this) to validateFirstForm(this).
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill for the reply.
I changed that it did not work.
The changing wont work because the name of my form in the
struts-config.xml is 'firstForm'
so validatefirstForm(this).
Please advise what needs to be done.
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi man, can you post the struts-config.xml and validator-rules.xml too
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like there may be other problems. It will help to have a look at the relevant portion of your struts-config.xml file.

Regarding the spelling issue: It's been my experience that Struts will normalize the capitalization of the JavaScript method regardless of whether your form name starts with an upper or lower case letter. You can verify this for sure by using your browser's "view source" function to see the JavaScript code that Struts added to your page. Look for the validateFirstForm function and you'll be able to see how it's capitalized. If you don't see any JavaScript code added to your page, you know there's some other problem.
[ July 25, 2007: Message edited by: Merrill Higginson ]
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Karthik and Merill for replying.

I checked the source , its generating the JS function



please help

thanks,
Saurav
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The part of your struts-config.xml file that I wanted to see with the action path definition for the action used in this form. Did you specify validate="true"?
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops........that might be the case......i will
check the code 2morrow as i dont have the code rite now
with me........need to check tommorow moring.....thanks
Merill for the pointer
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Merill again.....my validate option was kept as false.
Now its working fine after i tuned the struts-config.xml.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an example on Struts Client Side JavaScript Validation refer here. Struts Client Side JavaScript Validation
 
I brought this back from the farm where they grow the tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic