unobtrusive-validation

How to change 'data-val-number' message validation in MVC while it is generated by @Html helper

余生长醉 提交于 2019-11-26 08:00:19
问题 Assume this model: Public Class Detail ... <DisplayName(\"Custom DisplayName\")> <Required(ErrorMessage:=\"Custom ErrorMessage\")> Public Property PercentChange As Integer ... end class and the view: @Html.TextBoxFor(Function(m) m.PercentChange) will proceed this html: <input data-val=\"true\" data-val-number=\"The field \'Custom DisplayName\' must be a number.\" data-val-required=\"Custom ErrorMessage\" id=\"PercentChange\" name=\"PercentChange\" type=\"text\" value=\"0\" /> I want to

ASP.NET MVC implement custom validator use IClientValidatable

浪子不回头ぞ 提交于 2019-11-26 07:45:40
问题 I ask similar question here but in this question I use another implementation, exactly this way the following codes show my implementations: Model: public class Department { public long Id { get; set; } [IsDateAfter(\"Date2\", true, ErrorMessage = \"O My\")] public DateTime Date1 { get; set; } public DateTime Date2 { get; set; } public string Name1 { get; set; } public string Name2 { get; set; } } Custom Validator: public sealed class IsDateAfter : ValidationAttribute, IClientValidatable {

How to add a &#39;submitHandler&#39; function when using jQuery Unobtrusive Validation?

两盒软妹~` 提交于 2019-11-26 07:27:03
问题 I\'m validating a form using the new unobtrusive validation features in ASP.NET MVC 3. So there is no code that I have written to setup jQuery validate to start validating my form. Its all done by loading the jQuery.validate.unobtrusive.js library. Unfortunately I need to whack in a \'are you sure?\' message box when the form is valid but before submitting. With jQuery validate you would add the option handleSubmit when initialising like so: $(\"#my_form\").validate({ rules: { field1: \

Required field validations not working in JQuery Popup MVC 4

只谈情不闲聊 提交于 2019-11-26 01:24:06
问题 I have JQuery popups and i want to put required field validations on it and for this i have set required attributes in model and have also set the validation message for them in the view but that required field validations are not working on popups. Required field validation is working fine on forms other than JQuery Popups....Please guide me that what should i do to tackle this issue...Following is my code. Model [Display(Name = \"Material Code\")] [Required(ErrorMessage = \"*\")] public

jquery.validate.unobtrusive not working with dynamic injected elements

无人久伴 提交于 2019-11-25 23:43:47
问题 I am working with ASP.Net MVC3 , the easier way to use the client validation would be enabling the jquery.validate.unobtrusive . Everything works fine, for stuff that\'s right from server. But when I try to inject some new \'inputs\' with javascript, and I knew that I need to call $.validator.unobtrusive.parse() to rebind the validations. But still, all those dynamic injected fields are not functioning. Even worse, I try to manually bind using jquery.validate and it is not working either. Any