unobtrusive-validation

dynamically remove an element's required attribute in ASP MVC?

谁说胖子不能爱 提交于 2019-12-07 17:37:14
问题 Is there a way, in an ASP MVC project using unobtrusive validation, to dynamically remove the Required attribute from an element? The element is decorated with a Required annotation in the view model. I thought I could remove this by removing the html attribute, "data-val-required," with JQuery but client validation still treats the element as required. Is it impossible to manipulate the element's validation by manipulating the unobtrusive validation attributes? This is what I tried, but it

Override jQuery validate default settings in MVC4

自古美人都是妖i 提交于 2019-12-07 14:05:01
问题 To override the Query validate plugin, in the plaugsin document, the recommend way is: $(".selector").validate({ invalidHandler: function(form, validator) { var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } } }) However, it does not work in MVC4 with jquery

MVC4: jQuery Validation Unobtrusive Native working incorrectly

给你一囗甜甜゛ 提交于 2019-12-07 11:21:28
问题 My MVC4 web app is built on Umbraco 7. I have installed the following nuget packages: jQuery 1.10.2 jQuery.Validation 1.11.1 jQuery.Validation.Unobtrusive.Native.MVC4 1.1.0.0 The unobtrusive validation is from this website: http://jqueryvalidationunobtrusivenative.azurewebsites.net/Home/GettingStarted My view looks like this: <form id="frmContact" method="post" action="@Url.Action("ContactForm", "ContactFormSurface")"> <div> <label>Full Name</label> @Html.TextBoxFor(m => m.FullName, true)

Event hooks for MVC unobtrusive remote validation

核能气质少年 提交于 2019-12-07 05:58:17
问题 Is there a way to hook into MVC3 unobtrusive remote validation on the client, before data is submitted to the remote method, and after a result is returned from the remote method? I am trying to tell a remote validator to only perform validation if the submit button is clicked. The normal behavior is to validate several times, such as during keypress, blur etc. This is no good, as the validation method in question needs to call a non-idempotent operation. I need to make sure that method is

Using unobtrusive validation in ASP.NET MVC 3, how can I take action when a form is invalid?

天大地大妈咪最大 提交于 2019-12-07 04:26:45
问题 I have a page with jQuery UI tabs on it, and a single required field on the first tab. Validation works, and the validation message appears next to the field if the user hasn't entered a value. However, if the user is not on the first tab, it isn't obvious that the field is invalid. In this case, I would like to show the first tab, but I'm not sure how to go about registering a callback for an 'invalid' event, if there is one. I have also considered showing a validation summary above the tabs

MVC4 custom unobtrusive validator isn't working

南笙酒味 提交于 2019-12-07 04:23:08
问题 not sure what is wrong. Syntax seems correct.... but it still doesn't fire on client side. If I submit the form, I get server side validation, client side nothing... Here is the code that is on the page: <script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script> <script type="text/javascript"> // we add a custom jquery validation method (function ($) { $.validator.addMethod('additive', function

Validation Firing on Page Load

这一生的挚爱 提交于 2019-12-07 04:01:13
问题 Currently, I have an MVC 3 app using the Razor View engine. I have unobtrusive validation enabled. The problem is that for some reason, on page load, my Edit View is displaying errors for required fields (even though the fields have a value). Has anyone else ran into this? Any suggestions for resolving this? Thanks. Sample Field with problem: <div class="full"> <label>Description:</label> @Html.EditorFor(x=>x.Description, new{@class="super-textarea"}) @Html.ValidationMessageFor(x => x

Unobstructive client side validation for dynamically added input fields

做~自己de王妃 提交于 2019-12-07 02:25:29
I followed this excellent post for generating dynamic controls in my mvc3 app. And now I am trying to do client side unobstructive validation for phonenumber field. So I added 'Required' attribute on the 'PhoneNumber' property. The unobstructive validation works for the phonenumber fields which are generated/rendered by the server (i.e. on pageload). But it doesnt works for the fields that are dynamically added by javascript method. I know that I need to write some jquery code to add the rules/adapters or anything which notifies the browser that the dynamically added phonenumber fields needs

server side validation in jquery dialog

五迷三道 提交于 2019-12-07 01:50:42
问题 sorry for my language - in English i can only read :) i want to do in asp.net mvc something like this: 1. show user a page 2. open modal dialog (jquery-ui) and show partial view 3. validate user input data on client side 4. if it's OK then validate input data on server 5a. if it's OK then i want reload page 5b. if there is a errors i want show its to user 6. user can close dialog at any time with button on it. i have problem width 5a and 6. in Firefox when i do server validate and click close

Create a complex type model validation attribute with server and client validation

人盡茶涼 提交于 2019-12-06 14:32:01
I'm trying to create an attribute that can validate a complex type both on the server and client side. This attribute will be used for required and non required complex types such as the following Address Class public partial class AddressViewModel { [DisplayName("Address 1")] [MaxLength(100)] public virtual string Address1 { get; set; } [DisplayName("Address 2")] [MaxLength(100)] public virtual string Address2 { get; set; } [MaxLength(100)] public virtual string City { get; set; } [MaxLength(50)] public virtual string State { get; set; } [MaxLength(10)] [DisplayName("Postal Code")] public