This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

validating data in client side in a web application

Nadine Hossam
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35757
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Whatever. Here's a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!