unobtrusive-validation

Trigger an event if there are validation errors?

偶尔善良 提交于 2019-12-10 04:09:50
问题 I need to add an handle to any circumstance where a form validation fails. I've read this, that explains that I have to add a handler as follows: $('form').bind('invalid-form.validate', function () { console.log('form is invalid!'); }); But this event only fires when I try to submit the form. I need to handle an event that's fired ANY time the form is post-validated (i.e. element loses focus etc.). What I'm trying to achieve is, I have a large form (~50 fields), and it's splitted in Bootstrap

How to validate a list of checkbox through custom jQuery in asp.net mvc

╄→гoц情女王★ 提交于 2019-12-09 23:47:34
问题 I have a list of checkboxes that i want to validate on client side with jQuery but failing. I have already added unobtrusive and jquery validation plugin to my project. The Model code is: [Required] public string name { get; set; } [SkillValidation(ErrorMessage = "Select at least 3 skills")] public List<CheckBox> skills { get; set; } and other model is: public class CheckBox { //Value of checkbox public int Value { get; set; } //description of checkbox public string Text { get; set; } /

custom unobtrusive date validators for dates

好久不见. 提交于 2019-12-09 22:32:48
问题 Maybe it's just the way my mind works, but I have a very hard time understanding how you're supposed to do custom unobtrusive validators. The C# part is easy enough, but the jqueryui adapters are where i get lost. I've been trying to make a validator that requires a date to be a certain amount of time in the past. I use this for age validation, to make sure someone has entered a date that is 18 years in the past. I finally decided to just make it a remote validator, that way the validation

How to get unobtrusive jquery remote validator to perform async..?

坚强是说给别人听的谎言 提交于 2019-12-09 17:00:51
问题 In an MVC3 app, using jquery unobtrusive validation, and a view/model with a [Remote] validator: I am trying to disable the submit button and display a wait icon during remote validation, and when a valid form is submitted to the server. I thought I had it nailed until I tried it in IE8. The problem was, GC and FF were not firing the form's submit event when the form was invalid, so I just disabled the submit button during this event. However IE8 is firing this event when the form is invalid,

why I see validation messages before form submiting

倖福魔咒の 提交于 2019-12-08 07:00:56
问题 I've created a form and when I load the page with it I see validation messages before I submit the form. Why? You can download my code from github The similar question. It's because of mvc4 @model MyMustAgreeValidation.Models.NewUserProfileModel @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> @Html.MyEditFor(m=>m.Login) @Html.MyEditFor(m=>m.Password) @Html.MyEditFor(m=>m.ConfirmPassword) @Html.MyEditFor(m=>m.DisplayName) @Html.MyEditFor(m=>m.Email) @Html.MyEditFor(m=>m

Need approach to be able to validate div with elements(using unobtrusive/jquery validation plugin) without having any form on view

ε祈祈猫儿з 提交于 2019-12-08 06:40:17
问题 I have been assigned to a MVC3 project recently where i need to add client side validation to all of it's pages. unfortunately this project has many pages which don't have any form on it in entire page hierarchy of a given view(from layout till deepest partial view), though i know it's wrong and that jquery validation and so unobtrusive both need fields to validated to be kept inside form, but my hands are tied here as this project is running project since last 2 years and now entering into

Unobstructive client side validation for dynamically added input fields

喜欢而已 提交于 2019-12-08 05:41:57
问题 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

MVC validation Data Annotations are not rendering correct HTML5 attribute

守給你的承諾、 提交于 2019-12-08 04:26:15
问题 I am trying to understand why my MVC Data Annotations are not rendering the HTML 5 required tag. I think the problem is HTML5 & MVC related not JQuery validate. According to documentation here it is supported in all browsers yet the three I dev against, IE, Chrome, Firefox are not rendering the attribute? My scenario I thought was pretty simplistic. MVC controller populates a model then passes to the view. User completes fields and clicks submit. Validation ALWAYS passes even if the fields

Support two different validation messages per field/rule with unobtrusive validation

会有一股神秘感。 提交于 2019-12-08 03:30:32
问题 We are building an ASP.NET MVC3 web site using Fluent Validation with support for unobtrusive validation. Our UX team has asked if we can support two separate messages for validation, per field and per rule: one that would show next to the field, and a different one that would show in the summary. For example: Please address the following issues: - Please provide a First name - Please provide a Birth date First name: __________________ < First name is required > Birth date: __________________

Is there a way to change the position of validation message

让人想犯罪 __ 提交于 2019-12-08 02:05:51
问题 Although the validation messages in my project are positioned properly (just on the right side) for Textbox, Dropdownlist, etc. one of them is positioned on the left bottom for Editor and the position cannot be changed. So, is there a way to change the position of validation message for the Editor? I just want to change position of the validation message right side to the editor while not touching the position of the other controls. Any help would be appreciated. View: <script type="text