Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in Struts Validation

 
archana kaul
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by archana kaul:
[QB]

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

I think here u should say
onsubmit="return validateRoutingForm(this);">
ZHTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic