jQuery in Action, 2nd edition*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in Struts Validation" Watch "Problem in Struts Validation" New topic
Author

Problem in Struts Validation

archana kaul
Greenhorn

Joined: Oct 01, 2003
Posts: 5
Hi
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.
Thanks,
Manjunath
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Hi
instead of using normal javascript syntax u try ]
use this syntax for client side validation
<html:javascript formName= "formname"/>
if(validateFormname(document.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
Greenhorn

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">
<body>
<html:form action="/Routing" onsubmit="javascript:validateRoutingForm(this);">
<html:text property="hello"/>
<br>
<td><input type="submit" value="Route Message"></td>
</html:form>
<html:javascript formName="RoutingForm"/>
</body>
</html:html>
manasa teja
Ranch Hand

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

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

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


MT
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Struts Validation