Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 02, 2010 07:08 PM by ryanw51
Dec 02, 2010 03:09 PM|LINK
textbox is not valid. I am using dataannotations for client and server side validation.
Any advice / help would be appreciated. If more information is needed please let me know.
I am using ASP.Net MVC 2. I know that I could use jQuery in this situation but the idea was to try and somehow "tap" into the client validation that MVC does. By using jQuery we would basically be writing validation twice.
Thanks for everyones help so far. I'll let you know if I find out anything from some of the resources that you've pointed me towards.
Ajax and MVC
Dec 02, 2010 03:40 PM|LINK
I think not as build in functionality. But you could handle this very easily with jquery. Which version of asp.net mvc are u using?
Dec 02, 2010 04:12 PM|LINK
Dec 02, 2010 04:20 PM|LINK
You can use jQuery to evaluate the value of textbox. For example if your textbox is named as "txtEmail" then you can get its value like this:
var value = $("#txtEmail").val()
Now, are you doing AJAX post on textbox change event or button (click)?
Either way, you can check the value of the textbox using jQuery and cancel the AJAX post.
Dec 02, 2010 05:39 PM|LINK
I started studying the sources of the client validation linrary in these days for other reasons. There is a "validate"(this is its name) method of the fieldcontext class that do the validation. You can do some tests to see what happens calling it(find it
in the sources and see how it can be callled). However I fear that changes in the way client library is implemented may cause your program...stop working, because I don't know it it is intended for public use.
Dec 02, 2010 07:08 PM|LINK
If you're using MVC 3.0 unobtrusive validation with jquery validation, you can turn it off quite easily.
ignore: 'form *'
If you're using the microsoft client validation... eek.