what are the advantages of validation on the client side using a client side script such as Javascript?
thanks
what are the advantages of validation on the client side using a client side script such as Javascript?
thanks
The advantage is that the user doesn't need to reload the page just to find out that there's an error in the input. This said, you still have to do server-side validation, since users can turn off or manipulate the JavaScript in order to submit nonsense data to the server.
A better user experience. They get validation results quicker, without a server round-trip. It also allows you to do validation of fields that are difficult / you don't want to send back through a page cycle, such as passwords and credit card numbers.
It's fairly easy to set up nowadays - there's plenty of JavaScript frameworks you can just drop in, the set styles on your input fields to describe validation and wire up a submit handler to trigger validation. e.g. jQuery validate.
However you must always cope for the no-JavaScript case, and you must always server-side validate too.