This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Struts and the fly likes Problem in Struts Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in Struts Validation" Watch "Problem in Struts Validation" New topic

Problem in Struts Validation

archana kaul

Joined: Oct 01, 2003
Posts: 5
I am also working in the struts. I am new to strutrs framework. I want to do client side validation. I have declared the fields and validatins requried for the fields in the validatin.xml. I am extending the
ValidatorActionForm for my formbean.
When I run the form by not entering anything in the form and press submit sutton, it is forwarding to failure page and it is not showing the required message.
What should I do to enable to client side validation. I have not written any javascript method in validator-rules.xml. All I am doing is defininf the errors.required in my application resources file. I am expecting a error message when I keep the text box blank. Can you please tell me what are the steps I need to follow to enable the validation.
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
instead of using normal javascript syntax u try ]
use this syntax for client side validation
<html:javascript formName= "formname"/>
keep in minde
validateFormname here formname's F is capital and it is the syntax
after that u have to add this form name in validator.xml
and define the key for that fied
when u do this , u must have to add atleat one validation in validator.xml
archana kaul

Joined: Oct 01, 2003
Posts: 5
Hi santosh
Thanks for the reply. I have done this already. I am copying the code here. I declared defined this fomrname and the required validation in validator.xml. Still it is not going to the javascript function in validation-rules.xml file. If you have any idea, pl. help me.
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html locale="true">
<html:form action="/Routing" onsubmit="javascript:validateRoutingForm(this);">
<html:text property="hello"/>
<td><input type="submit" value="Route Message"></td>
<html:javascript formName="RoutingForm"/>
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Originally posted by archana kaul:

<html:form action="/Routing" onsubmit="javascript:validateRoutingFormQB]

I think here u should say
onsubmit="return validateRoutingForm(this);">

I agree. Here's the link:
subject: Problem in Struts Validation
It's not a secret anymore!