• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Validation failure

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new in struts.. i'm trying to check validation on login form on client side,but i'm failure to do this again and again.The warning massege does not come on browser.Can any body help me....

Following is my code:-

struts-config.xml

<message-resources parameter="ApplicationResources" null="false" />


<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

validation.xml

<form-validation>
<formset>
<form name="loginForm">
<field property="username" depends="required">
<arg0 key="prompt.username"/>
</field>
<field property="password" depends="required">
<arg0 key="prompt.password"/>
</field>
</form>
</formset>
</form-validation>

validator-rules.xml

<form-validation>

<global>

<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

</global>
</form-validation>

ApplicationResources.properties

prompt.username=Enter Name:
prompt.password=Enter Password:

login.jsp

<body>
<html:img align="left" border="0" height="37px" width="191px" page="/image/iotl logo.jpg" />
<html:link page="/jsp/registration.jsp"><br><br>
<hr width="100%" size="3">New User</html:link>
<center>
<html:form action="/login" method="post" focus="username" onsubmit="return validateloginForm(this);">

<html:errors />
<pre>
Login Page
</pre>
<table border="0" width="238" height="60">
<tr>
<td>User Id:</td>
<td><html:text property="username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><html assword property="password" /></td>
</tr>
</table>
<table width="101" height="32">
<tr>
<td colspan="2" align="center"><html:submit /></td>
</tr>
</table>

<!-- Begin Validator Javascript Function-->
<html:javascript formName="loginForm" />
<!-- End of Validator Javascript Function-->

</html:form>
</center>
</body>
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Put this line above <body> tag ..



Make the "validateloginForm" s, first letter capital , like validateLoginForm(this);

HTH
 
Subhradip Podder
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it.... but same thingh will happen
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please copy paste your <action ..> tag for login ,
and see this and this link for details .
 
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic