-6

Possible Duplicate:
JavaScript: client-side vs. server-side validation

Hi I am beginner in jsp and servlet. I like to know if its better to use servlet or javascript to do form validation. what are the pros and cons for both methods? Thank you!

Community
  • 1
  • 1
  • 1
    Have you tried searching for key words like "server side vs client side validation" ? – Umer Hayat May 31 '12 at 09:26
  • I'm Feeling Lucky on Google for "server side vs client side validation" returns [JavaScript: client-side vs. server-side validation](http://stackoverflow.com/questions/162159/javascript-client-side-vs-server-side-validation) – adarshr May 31 '12 at 09:27

2 Answers2

1

You always have to do a validation on the server side, because:

  • Validation is often related to security and data integrity, and any skilled javascript developper could use the browser's debugger to forge requests that would by pass client - side validation.
  • if you have later another screen that uses the same service on the server side, you don't have to completely rewrite the validation

And for more fluidity of your application, you can also do a validation on the client side. For the client side, you can use this excellent plugin

Samuel Rossille
  • 18,940
  • 18
  • 62
  • 90
0

For validation such as to check whether the email address entered is in correct format, or whether the first name field is all characters, or whether the phone number entered is number and not characters, you can use client side validation.

But for user credentials validations and other similar validations(security and data integrity) you should use server side validation.

Susie
  • 5,038
  • 10
  • 53
  • 74