aspose file tools*
The moose likes Struts and the fly likes validating data in client side in a web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validating data in client side in a web application" Watch "validating data in client side in a web application" New topic
Author

validating data in client side in a web application

Nadine Hossam
Greenhorn

Joined: Jun 19, 2005
Posts: 13
Hi,
I'm developing a web application using Struts framework.

and my questions is, does the validate method int the ActionForm replaces the using javascript validation?

If I can do all the validations in this validate method, so does that mean that i'm not going to use JS at all?

For example if I need to check if a field has been entered, or for the field's length
Should I do that using JS validation, or the validate method in form bean.

if they are working the same way, so I guess it would be more efficient to be written in the ActionForm
[ July 22, 2007: Message edited by: Nadine Hossam ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30919
    
158

Nadine,
You can choose whether to do the validation instead of or in addition to the JavaScript. Many people prefer to have both as users see errors earlier. This is especially useful for required fields. If I leave out a required field, should I have to wait for a server roundtrip to find out?

For field lengths, you can use an HTML attribute to restrict length so the JavaScript is not necessary. Of course there is no harm since Struts can generate the JavaScript validation for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validating data in client side in a web application