am i correct in doing this?

Answer this question

  • am i correct in doing this?


Answer #1 | 22/12 2013 21:59
Doing form validation with JavaScript doesn't eliminate the need to do form validation on the server side. All it does is allow you to provide feedback to the user quicker, because you don't have to go back to the server to validate when JavaScript is enabled. A malicious user can easily disable tests in your form validation JavaScript code, and submit whatever invalid data they want to submit. They don't even have to look at the JavaScript. They can use a program like Tamper Data (Firefox plugin) to modify the submit data after you validate it, but before it is sent to the server. There is no way you can know that that is happening. If you only need JavaScript for validation, not for other features of your site, then don't require it. Just do the server side validation and report the error if the data is invalid. Then your page works with our without JS, it just works better with it.
Answer #2 | 22/12 2013 22:01
You could add a function that handles errors, if javascript was turned off you could divert to your errorHandler on some page error and check to see if javascript was on or off then act appropriately. Generally though, If someone turns javascript off in the middle of your page flow, then well they should expect odd results. I think checking on page load is fine enough.
Answer #3 | 22/12 2013 23:58

Possible answer