Questions tagged [unobtrusive-validation]

Unobtrusive Validation refers to a jQuery plugin created by Microsoft used in conjunction with the jQuery Validate plugin. It is shipped with ASP.NET MVC 3.

Unobtrusive Validation is a jQuery plugin written by Microsoft that acts as a support library for jQuery and the jQuery Validate plugin.

The script is shipped as part of ASP.NET MVC 3 and is included in new Visual Studio 2010 MVC 3 projects by default. It uses HTML5 data attributes (data-val-*) usually originating from DataAnnotation attributes on the view's model.

1239 questions
171
votes
4 answers

What is jQuery Unobtrusive Validation?

I know what the jQuery Validation plugin is. I know the jQuery Unobtrusive Validation library was made by Microsoft and is included in the ASP.NET MVC framework. But I cannot find a single online source that explains what it is. What is the…
137
votes
4 answers

What is the best way of adding a greater than 0 validator on the client-side using MVC and data annotation?

I'd like to be able to only allow a form to submit if the value in a certain field is greater than 0. I thought maybe the Mvc Range attribute would allow me to enter only 1 value to signify only a greater than test, but no luck there as it insists…
jaffa
  • 26,770
  • 50
  • 178
  • 289
104
votes
8 answers

unobtrusive validation not working with dynamic content

I'm having problems trying to get the unobtrusive jquery validation to work with a partial view that is loaded dynamically through an AJAX call. I've been spending days trying to get this code to work with no luck. Here's the View: @model…
Sam
  • 13,934
  • 26
  • 108
  • 194
103
votes
13 answers

jquery.validate.unobtrusive not working with dynamic injected elements

I am working with ASP.Net MVC3, the easier way to use the client validation would be enabling the jquery.validate.unobtrusive. Everything works fine, for stuff that's right from server. But when I try to inject some new 'inputs' with javascript,…
xandy
  • 27,357
  • 8
  • 59
  • 64
78
votes
14 answers

How to change 'data-val-number' message validation in MVC while it is generated by @Html helper

Assume this model: Public Class Detail ... Public Property PercentChange As Integer ... end class and the view: @Html.TextBoxFor(Function(m)…
65
votes
21 answers

MVC 4 client side validation not working

Can anyone tell me why client side validation is not working in my MVC 4 application. _layout.schtml @Scripts.Render("~/bundles/jquery") @RenderSection("scripts", required: false) In my web.config I have:
Javid
  • 821
  • 2
  • 8
  • 13
62
votes
2 answers

Revalidating a modified ViewModel within a controller method?

EDIT - We're using MVC4 Dev Preview.... I'm implementing an edit page for a FishingTrip class. FishingTrip contains a child collection of simple Crew objects (i.e. FishingTripID, CrewID, CrewPosition). I'm using Jarrett Meyer's approach to add,…
Merenzo
  • 5,326
  • 4
  • 31
  • 46
61
votes
7 answers

Error in jquery.validate.js in MVC 4 Project with jQuery 1.9

I created a new ASP.Net MVC 4 project using the template in Visual Studio 2012. After upgrading to jQuery 1.9, the login functionality breaks. Specifically, I get the error 0x800a138f - JavaScript runtime error: Unable to get property 'call' of…
Eric J.
  • 147,927
  • 63
  • 340
  • 553
55
votes
12 answers

Unobtrusive validation in Chrome won't validate with dd/mm/yyyy

I'm trying to use the simplest possible scenario using a date picker in different browsers. I suspect I'm doing something very simple the wrong way but after lots of searching around I still haven't found a solution. Below is some sample code that…
sipsorcery
  • 30,273
  • 24
  • 104
  • 155
55
votes
2 answers

How to fire jQuery function only if form is valid

I have a jQuery function tied to my submit button like this: $(function () { $('#signupform').submit(function () { alert('test'); }); }); However, it fires whether or not the form is valid. My model is decorated with various…
Scott
  • 13,735
  • 20
  • 94
  • 152
50
votes
5 answers

How to add a 'submitHandler' function when using jQuery Unobtrusive Validation?

I'm validating a form using the new unobtrusive validation features in ASP.NET MVC 3. So there is no code that I have written to setup jQuery validate to start validating my form. Its all done by loading the jQuery.validate.unobtrusive.js…
WooWaaBob
  • 3,397
  • 3
  • 23
  • 23
47
votes
2 answers

Unobtrusive validation not working on dynamically-added partial view

I am currently facing a problem with validation after dynamically adding content. I have a view strongly typed to a model (Order). This Order can have many items. The model looks something like the following: public class Order { [Key] …
39
votes
1 answer

ASP.NET MVC 3: Required steps for unobtrusive client-side validation of dynamic/AJAX content

What are the complete set of Steps Required for client-side unobtrusive validation to work for dynamically inserted form fields? Relevant SO posts ASP.NET MVC 3 unobtrusive client-side validation with dynamic content - He needed the unobtrusive…
Kaleb Pederson
  • 45,767
  • 19
  • 102
  • 147
38
votes
5 answers

Validation type names in unobtrusive client validation rules must be unique

Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required This is referring to the EmailAddress property, here: public class LoginModel { [Required] …
Josh M.
  • 26,437
  • 24
  • 119
  • 200
38
votes
5 answers

MVC3 Unobtrusive Validation Not Working after Ajax Call

Ok, here is the deal, I have seen a few posts on SO relating to this issue, but nothing is working for me. Basically, I have select drop downs that are being loaded from partial views, I am trying to filter contents of each subsequent drop down,…
David C
  • 3,610
  • 3
  • 21
  • 23
1
2 3
82 83