Reputation: 1032
Hi I am developing a web app using asp.net mvc with knockout
I wanted to know if there is a way to use JavaScript to do server side validation or would it be best to use the model?
Upvotes: 0
Views: 265
Reputation: 1039408
Javascript to do server validation? Hmm. What if javascript is disabled? Or even worse: what if someone intentionally disables javascript and sends to your server whatever garbage he likes?
The answer to your question is: no. Absolutely never rely on javascript to do validation. At minimum do validation on the server using whatever you like (Data Annotations or personally I prefer FluentValidation.NET). Client validation is a bonus. It allows for more responsive interfaces, improves user experience, reduces bandwidth usage, ... But exactly as bonuses, you can live without it. What you can't live without is the server side validation which is your main source of revenue.
Upvotes: 1