asp.net mvc client side validation; manually calling validation via javascript for ajax posts
Posted
by Jopache
on Stack Overflow
See other posts from Stack Overflow
or by Jopache
Published on 2010-03-31T07:18:40Z
Indexed on
2010/03/31
7:23 UTC
Read the original article
Hit count: 482
Under the built in client side validation (Microsoft mvc validation in mvc 2) using data annotations, when you try to submit a form and the fields are invalid, you will get the red validation summary next to the fields and the form will not post. However, I am using jquery form plugin to intercept the submit action on that form and doing the post via ajax. This is causing it to ignore validation; the red text shows up; but the form posts anyways. Is there an easy way to manually call the validation via javascript when I'm submitting the form? I am still kind of a javascript n00b. I tried googling it with no results and looking through the js source code makes my head hurt trying to figure it out.
Or would you all recommend that I look in to some other validation framework? I liked the idea of jquery validate; but would like to define my validation requirements only in my viewmodel. Any experiences with xval or anything of the sort?
© Stack Overflow or respective owner