Reputation: 1781
Suppose I have a form and I wanna prevent the user from submiting the form before validating, so that I use the event.preventDefault() in onsubmit :
// In my validation.js
$('#myForm').bind('submit', function(event){
event.preventDefault();
// I do the client-side validation here
});
You can see here, the user can edit the validaiton code after preventDefault() line. And they pass the validation (only client side)
What is the more secure way to make a form 'ajax' with client-side validation? I have the server-side validation too, but I just wanna ask how to make the client-side one harder to crack and more secure?
Upvotes: 4
Views: 1842
Reputation: 1
You should duplicate all your client side validation on the server. A better solution if using .NET would be to use Dataannotaion to decorate your entity classes with Required, Range, Regularexpression attributes. These attributes can be validated client side using jquery.unobtrusive.validate and then on serverside using ModelState.IsValid()
Upvotes: 0
Reputation: 6522
You can't make it completely secure client side, but you can increase security. Amongst other things you could do are:
Upvotes: 0
Reputation: 50966
It's never "more reliable" or "more secure". JS can be disallowed and there would be no validation on client-side.
Upvotes: 1