• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validating data in client side in a web application

 
Nadine Hossam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34973
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic