unobtrusive-validation

Validate prefilled jQuery form (invalidate on first field clear, ASP.NET and unobtrustive)

牧云@^-^@ 提交于 2019-11-30 18:53:42
问题 I have a form that can be filled, saved, loaded and re-edited. When it is loaded and re-edited, it probably begins its life valid. When a field is valid upon load, I want it to invalidate immediately when it is edited contrary to rules. That's my question in a nutshell, and I suspect this is supported by some configuration option I can't find. Currently, it works properly (the way desired above) only after: 1) it is edited, 2) then the field loses focus while valid, 3) then is edited it again

Where can one download Microsoft jQuery Unobtrusive Validation without using NuGet

萝らか妹 提交于 2019-11-30 17:00:40
I'd like to download the latest version of Microsoft jQuery Unobtrusive Validation, however I don't like using NuGet since it is not possible for me to tell it where to install the packages within my project structure. Does Microsoft host these files somewhere that I can access them directly? Kenny Evitt The files for ASP.NET MVC 5.2 aren't (yet?) on the page I mention below, but the links are valid: http://ajax.aspnetcdn.com/ajax/mvc/5.2/jquery.validate.unobtrusive.js http://ajax.aspnetcdn.com/ajax/mvc/5.2/jquery.validate.unobtrusive.min.js [Copied from Maxime's answer to this question.] I

jQuery Unobtrusive client-side validation of custom attribute

狂风中的少年 提交于 2019-11-30 15:32:45
问题 I have created a custom validation attribute which works server-side (after form is posted) but I cannot get the validation to work client-side. The custom attribute is: public class ReasonableAttribute : ValidationAttribute, IClientValidatable { public override bool IsValid(object value) { return Approval.IsNumberReasonable(value.ToString()); } public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { ModelClientValidationRule

jQuery Unobtrusive client-side validation of custom attribute

こ雲淡風輕ζ 提交于 2019-11-30 14:10:49
I have created a custom validation attribute which works server-side (after form is posted) but I cannot get the validation to work client-side. The custom attribute is: public class ReasonableAttribute : ValidationAttribute, IClientValidatable { public override bool IsValid(object value) { return Approval.IsNumberReasonable(value.ToString()); } public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { ModelClientValidationRule rule = new ModelClientValidationRule(); rule.ErrorMessage = FormatErrorMessage(metadata.GetDisplayName

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

China☆狼群 提交于 2019-11-30 10:40:19
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 on Minimum AND Maximum values. Any ideas how this can be achieved? You can't store a number bigger than what your underlying data type could hold so that fact that the Range attribute requires a max value is a very good thing. Remember that ∞ doesn't exist in the real world, so the following should work: [Range(1, int.MaxValue, ErrorMessage = "Please

MVC-3/jQuery: stop validating my checkbox

假如想象 提交于 2019-11-30 09:59:48
问题 I have MVC-3 user control (html helper & aspx view engine). Some how when I submit the form jQuery un-obtrusive validation fires up & requires me to check all checkboxes. How do I prevent it? Further Info: 1) There is no required attribute in my model. 2) I am using this check-box inside telerik gridview namespace Alpha.Views { public class AlphaCheckBoxControl : ViewUserControl<AlphaCheckBox> { } public class AlphaCheckBox { public bool isChecked; public string name { get; set; } public

MVC Remote Validation With Additional bool Fields

风流意气都作罢 提交于 2019-11-30 09:40:32
问题 I am trying to use Remote Validation with an additional bool checkbox field [Remote("IsStorageConnectionValid", "TenantManagement", AdditionalFields = "CreateStorage")] public String StorageConnectionString { get; set; } Validation code public JsonResult IsStorageConnectionValid(string storageConnectionString, bool createStorage){ It works perfectly in terms of it hitting the validator. However createStorage is always true irrespective of the value of the checkbox. If I use additional fields

ASP.NET MVC validation message does not get localized

蹲街弑〆低调 提交于 2019-11-30 08:47:16
I am using ASP.NET MVC 4 with unobtrusive clientside validation. The language in my application is german (defined in the web.config file) If i have a required field (configured with data-annotations in my Code First Classes), the client side validation works fine. the only downside: The Message is not Localized. The Field XXXX is required. Is there a solution out for this problem? You must install the .NET Framework Language pack, according to your .NET Framework version: Microsoft .NET Framework 4.5 Language Pack: http://www.microsoft.com/de-de/download/details.aspx?id=30667 Microsoft .NET

ASP.Net MVC 3 - Client side unobtrusive validation for Editor Templates

萝らか妹 提交于 2019-11-30 07:24:05
I am new to ASP.Net MVC 3, facing some issues while trying to implementing client side unobtrusive validation for a editor template I have created for showing date in a custom way. UI I need to show date in a three texbox UI format as I have put up a EditorTemplate for displaying the date in three parts as @model DateTime? <table class="datetime"> <tr> <td>@Html.TextBox("Day", (Model.HasValue ? Model.Value.ToString("dd") : string.Empty)) </td> <td class="separator">/</td> <td>@Html.TextBox("Month", (Model.HasValue ? Model.Value.ToString("MM") : string.Empty))</td> <td class="separator">/</td>

Trouble getting unobtrusive validation working with mvc 3 on jquery ajax post

[亡魂溺海] 提交于 2019-11-30 06:57:02
问题 I have having a lot of trouble getting validation to work on MVC3. It works fine when I just load the page directly, but it does not validate when I use jquery AJAX POST: This form is loaded using $('#modal-dialog').load('/DartsMVC/Restaurant/Edit/13') , This is the rendered HTML: <form action="/DartsMVC/Restaurant/Edit/13" method="post"> <fieldset> <legend>Restaurant</legend> <input data-val="true" data-val-number="The field RestaurantID must be a number." data-val-required="The RestaurantID