1

I am curious as to what other methods there are for form validation. Currently the solution is .NET 4, MVC 3, and the form post is a traditional non-Ajax post. Obviously there are many ways to go about validating the form post, but my question is this, without utilizing DataAnnotations, in your opinion what is the best client-side validation method? The form also has several radio-button groups that are being generated via a foreach, these radio-buttons will also need to be null-checked and validated.

  1. What downstream impact will the implimentation of DataAnnotations, as well as enabling client side validation have on the pre-existing forms?

Thank you in advance!

Ryan
  • 295
  • 2
  • 8
  • plain javascript validation. document.getElementById("id") stuffs and validation – Ravi Gadag May 07 '13 at 05:26
  • why not use DataAnnotations,its the way to go. – Prabhu Murthy May 07 '13 at 05:30
  • I am an engineer working in a small task within a very very large project, I like to refrain from touching the webconfig as much as possible. But if I were to enable dataAnnotations for the portion(form) I am actively developing, will this cause any negative downstream impact to pre-existing code. I could just make the changes and test, but if anyone could save me 40 minutes of UT's and UI testing I would greatly appreciate it =) – Ryan May 07 '13 at 05:34
  • 1
    If you don't want to use DataAnnotations then you are going to have to implement the validation manually in the controller. If you want to have some client side validation then you're going to need to implement the same logic client side with something like jquery validate. That being said, turning on DataAnnotations shouldn't break anything. – Neophyte.net May 07 '13 at 06:09

1 Answers1

0

I wasn't aware dataannotations could be turned off. He's right in that you can always validate it on the server side. Maybe you can use a ValidationContext*. you may still have to create a matching viewmodel with data annotations and use the proper refs.

Q: how was DataAnnotations turned off / how do you turn it off? Thanks

Community
  • 1
  • 1
monkeyhouse
  • 2,875
  • 3
  • 27
  • 42