• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Problem in Struts Validation

 
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
 
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>
 
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
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!