unobtrusive-validation

Manually bind JQuery validation after Ajax request

依然范特西╮ 提交于 2019-12-30 05:02:07
问题 I'm requesting an ASP.net MVC view into a live box and the view contains form fields that have been marked up with attributes to be used by JQuery's unobtrusive validators plug-in. The client script is not however working and my theory is that its because the validation framework is only being triggered on page load which has long since passed by the time the MVC view has been loaded into the live box. Thus how can I let the validation framework know that it has new form fields to fix up?

MVC 3 unobtrusive validation - conditionally disable/enable validation

◇◆丶佛笑我妖孽 提交于 2019-12-29 08:43:08
问题 I have a form that has an option to enter dimensions for: Width & Height Width Height And I have two container divs that I hide/show depending on which of the three options is selected: <div class="editor-field" id="width-container"> @Html.EditorFor(model => model.Width) @Html.ValidationMessageFor(model => model.Width) </div> <div class="editor-field" id="height-container"> @Html.EditorFor(model => model.Height) @Html.ValidationMessageFor(model => model.Height) </div> If height is selected,

How to use Html.GetUnobtrusiveValidationAttributes()

我是研究僧i 提交于 2019-12-29 06:19:53
问题 I am trying to work around the fact that when they wrote asp.net MVC 3 they forgot to include code to add the unobtrusive validation attributes to select lists and their "fix" for this is to include it in MVC 4, which is no bloody use to anyone using MVC 3. My proposed work around is to use Html.GetUnobtrusiveValidationAttributes() to add them myself, just like any other custom attributes, but i can't work out the correct syntax for calling the method. There are 2 overloads, one takes a

jQuery Validation remote with invalid variable name: How to fix?

戏子无情 提交于 2019-12-29 02:02:28
问题 I'm using remote validation with jQuery Validation. I'm trying to call my server side code in MVC but the problem is that my variable is in a nested class: public class Customer { public State HouseState {get;set;} } public class State { public string Name {get;set;} } In my *.cshtml I have this: @Html.TextBoxFor(m => m.HouseState.Name, new { placeholder = "State Name"}) I'm adding validation with this: $.validator.addMethod("verify", verify); $('#HouseState_Name').rules('add', { verify: true

Validation type names in unobtrusive client validation rules must be unique

十年热恋 提交于 2019-12-28 05:57:39
问题 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] [DataType(DataType.EmailAddress)] [Display(Name = "Email")] [AdditionalMetadata("Style", "Wide")] public string EmailAddress { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] [AdditionalMetadata("Style", "Wide")] public string

Validation type names in unobtrusive client validation rules must be unique

我与影子孤独终老i 提交于 2019-12-28 05:57:02
问题 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] [DataType(DataType.EmailAddress)] [Display(Name = "Email")] [AdditionalMetadata("Style", "Wide")] public string EmailAddress { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] [AdditionalMetadata("Style", "Wide")] public string

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

僤鯓⒐⒋嵵緔 提交于 2019-12-28 04:59:15
问题 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 undefined or null reference at line 1172, column 5 in jquery.validate.js How can I fix this issue? 回答1: This issue is fixed in jQuery Validation Plugin 1.11.0pre . Unfortunately there is currently no pre-release build on NuGet, so it is currently

Jquery Unobstrusive validation show errors manually for Valid

回眸只為那壹抹淺笑 提交于 2019-12-25 17:18:57
问题 I have added errors manually to my input using the link in here Here and the example in Here but when I try $("#myshowErrors").valid() after I added the errors it becomes true? here is my code var validator = $( "#myshowErrors" ).validate(); validator.showErrors({ "firstname": "I know that your firstname is Pete, Pete!" }); I am not able to make the client validation fail. How can I make form.valid() to return false ? I don't want to make form.valid()=false; manually I want that to be taken

Unobtrusive validation not working on jquery tabs using partial view

房东的猫 提交于 2019-12-25 12:51:26
问题 I'm using jquery-ui tabs to display partial views. I have a view that contains the tabs definition: <ul> <li><a href="@Url.Action("CreateTab","Catalogue")">Create</a></li> ... And a controller method CreateTab which returns a PartialView: public ActionResult CreateTab() { var model = new StockCatalogueItemViewModel { ... populate some selectlists } return PartialView(model); The model property that I'm validating has datatannotations on and I can see that the validation tags have been

Trigger modal if submitting valid form in ASP.NET MVC 5 application?

情到浓时终转凉″ 提交于 2019-12-25 11:57:06
问题 I am creating an ASP.NET MVC 5 application. There is a long wait time between the user clicking the "submit" button and the next page to load, so I would like a "please wait" modal to pop up only if the user has submitted a valid form. I have tried the following code, which causes the modal to pop up no matter if the form is valid or not: $('form').submit(function () { $('#waitingModal').show(); }); My application utilizes the jQuery Validate plugin and unobtrusive validation which both came