unobtrusive-validation

MVC4 - Unobtrusive validation starting too early

不打扰是莪最后的温柔 提交于 2019-12-06 12:08:40
问题 I have a HTML form that uses unobtrusive validation in my website which is an ASP.Net MVC4 application. The form from my view is simple and is shown below @Using (Html.BeginForm()) { @: Listing for @ViewBag.itemNumber @Html.TextBoxFor(model=>model.Name) @Html.TextBoxFor(model=>model.Location) @:<input type="submit" value="Save" /> } My controller is as shown below public ActionResult test() { string itemNumber = Request.params["item"]; ViewBag.itemNumber = itemNumber; return View(); } and my

Replacement for TextAreaFor code in Asp.net MVC Razor

China☆狼群 提交于 2019-12-06 09:19:53
问题 Following is my model property [Required(ErrorMessage = "Please Enter Short Desciption")] [StringLength(200)] public string ShortDescription { get; set; } And following is my corresponding View code @Html.TextAreaFor(model => model.Product.ShortDescription, new { cols = "50%", rows = "3" }) @Html.ValidationMessageFor(model => model.Product.ShortDescription) And this is how it shows in the browser, the way i want. Now, since there is a bug in Microsoft's MVC3 release, I am not able to validate

ASP.NET MVC 3 unobtrusive jQuery client-side validation with child collections

北战南征 提交于 2019-12-06 06:48:32
问题 Related questions: ASP.NET MVC 3: Generate unobtrusive validation when BeginForm is on the layout ASP.NET MVC 3 unobtrusive client-side validation with dynamic content I have an ASP.NET MVC view rendering a collection of items which the user can add to:- <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MySite.Models.Parent>" %> <% using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true) %> <%: Html.HiddenFor(model => model.Id)

Custom clientside validation for required at least one in array

痞子三分冷 提交于 2019-12-06 06:09:46
I have the following custom attribute that is used to validate if an array has had a value submitted: [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)] public sealed class RequiredArrayAttribute : RequiredAttribute, IClientValidatable { public RequiredArrayAttribute() : base() { } public override bool IsValid(object value) { var list = (IList)value; if (list != null && list.Count > 0) { return true; } return false; } public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { string errorMessage =

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

戏子无情 提交于 2019-12-06 06:04:36
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: __________________ < Birth date is required > Notice the field-level and summary-level validation messages are different.

Is there a way to change the position of validation message

≯℡__Kan透↙ 提交于 2019-12-06 05:29:49
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/javascript"> $(function () { $("form").kendoValidator({ //Hide Kendo validation message and show as tooltip

jQuery unobtrusive custom adapter and method in jsFiddle

早过忘川 提交于 2019-12-06 03:37:58
I cannot make this jsFiddle work but it works in the browser: http://jsfiddle.net/vtortola/jYq2X/ I am trying to add a new custom rule to compare two fields. The custom adapter works, it is being called and setting the options. But the custom method is never called. I am executing this JS on DOM ready: $.validator.addMethod("customequal-method", function (val, el, p) { var $other = $(el).closest('form').find('input[name=' + p.other + ']'); return $other.length && $other.val() == val; }); $.validator.unobtrusive.adapters.add("customequal", ["other"], function (options) { options.rules[

ASP.NET MVC RemoteAttribute validation not working - Action not being executed

你说的曾经没有我的故事 提交于 2019-12-06 03:28:54
问题 I've been pulling my hair out trying to figure out why ValidationController actions are not being triggered. I have settings enabled in project-wide web.config: <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> I have the following controller: [OutputCache(Location = OutputCacheLocation.None, NoStore = true)] public class ValidationController : Controller { private readonly IUserRepository userRepository; public ValidationController

Override jQuery validate default settings in MVC4

痞子三分冷 提交于 2019-12-05 21:42:28
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-1.7.1.js. it seems jquery.validate.unobtrusive.js prevent the override handle to be called. If do not

Remove required validation using asp.net core

不羁的心 提交于 2019-12-05 20:14:11
I have a client that requires two buttons on the form. One that saves the progress of an uncompleted form. So this form will still need to validate the fields but will just ignore the required validation. The other button will need to run the complete validation included required fields. I am using the stock standard asp.net core project which I believe uses jquery-validation-unobtrusive and is based on the model for the view. What I am trying to do is when the "Save Progress" button is clicked to remove all the required validation and submit the form. However none of the code that I have