Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validator framework

 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing validatefirstForm(this) to validateFirstForm(this).
 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
Karthik Rajendiran
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • 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
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
Nyanas Kandhan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For an example on Struts Client Side JavaScript Validation refer here. Struts Client Side JavaScript Validation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic