File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validator Framework

 
Jack Lau
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I configurate the validator with struts it works but both client-side javascript error message and server-side error message are show. Does any one tell me how to configurate the validation.xml in order to allow only client-side validation ?

Thanks,
Jack
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want that. The client-side validation is not complete, and tightly locked down clients may not run your JavaScript at all. You always must have server-side validation whatever you do. Your problem is probably an incorrect implementation of the client-side validation scripts. Please show us what you've got there.

- Peter
 
Jack Lau
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code are listed below:

In register.jsp
[CODE]
<html>
<html:form action="/Register" onsubmit="validateRegisterForm(this)">
<table>
<tr>
<td>User ID:</td>
<td><html:text property="userId" size="20"/></td>
</tr>
</table>
</html:form>
<html:javascript formName="registerForm"/>
</html>
[CODE]
In validation.xml
[CODE]
<field
property="userId"
depends="required, mask, minlength, maxlength">
<msg name="mask" key="register.userId.mask"/>
<msg name="minlength" key="register.userId.minlength"/>
<msg name="maxlength" key="register.userId.maxlength"/>
<arg0 key="register.userId.displayname"/>
<arg1 nam="minlength" key="${var:minlength}" resource="false"/>
<arg2 nam="maxlength" key="${var:maxlength}" resource="false"/>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z0-9]*$</var-value>
</var>
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
<var>
<var-name>maxlength</var-name>
<var-value>12</var-value>
</var>
</field>
[CODE]

Any problem ?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TryHope it's as simple as this

- Peter
 
Jack Lau
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!

Jack
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic