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

Struts Validator

Anoop Retnakumar

Joined: Feb 09, 2008
Posts: 1
I have a struts application in which all the client side validations are done using Validator framework. For mandatory checks i will get a alert message in an alert box. Now I need to replace this message box and I need to display the message in the JSP page itself just beside of the mandatory fields. Please help me in this regard.
Thank you
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 471

To get an alert box, you use the <html:javascript> tag to generate the validation javascript, and in your form you use the onsubmit attribute to call the validate method. To do what you want, you have to have the following
1- Remove the onsubmit attribute from the html form
2- Make sure that you have validate="true" in the struts-config's action you want to validate
3- Make sure that the input attribute of that action points to the JSP
4- Use <html:errors> to display the errors on the JSP page

Visit my blog:
I agree. Here's the link:
subject: Struts Validator
jQuery in Action, 3rd edition