Dependence on Java Script for form validations


Web tier: servlets, JSP, Web frameworks: Dependence on Java Script for form validations

  1. I am involved in building in a J2EE application where we are using Struts combined with JSPs for the presentation logic. Currrently we are using JavaScript for form validations, i.e, if a customer has to enter his/her Name in a form, we are using Javascript to check whether this is left blank or not.

    Is this a good practice ? Or should we be doing the form validation using Struts itself, using the ActionError classes ?
  2. I think it's a good practice. But don't forget taht y must validate user inputs on the server side too. I don´t know too much Struts, but take a look at Struts Validator with its declarative XML validations. It´s a good way for validating user inputs :).
  3. Never trust user input. You ALWAYS have to do the validation at the server. Client-side validation is just a bonus if you have the time.