General J2EE: Does one need java script validation in Struts Application!

  1. Can anybody please tell me whether validation should be done inside form classes under struts framework or by using java script.
  2. I don't think there is one line answer for your question. It largely depends on what you are trying to do.

    Using Java Script could limit the portability of your applications across browsers. At the same time, JavaScript could help to minimize the network trips if you could do the validation with the data available on the client side.

    In some cases you might have to go back to middle-tier to get the validation as it might require access to some data in other form classes.

  3. What ever happens you shoudl duplicate any validation that you do in JavaScript in the Struts code as well because there is always the possibility that the user has switched JS off in the browser. The Struts Validator plug-in makes this simple as you just define the rules once and it will enforce them on the server and in JavaScript automatically