unobtrusive-validation

Using Foolproof RequiredIf on multiplecondition

若如初见. 提交于 2019-12-11 10:26:45
问题 I have a dropdownlist named CustomerType with the the following values Id Name 1 Student 2 Non-Employed 3 Employed 4 SelfEmployed and I have one more property in my viewmodel public string CompanyAddress{ get; set; } My goal is to make CompanyAddress required if dropdownlist has values 3 or 4 I have tried the following but gets error Cannon have duplicate RequiredIf [RequiredIf("customerTypeID", 3, ErrorMessage = "Please enter company address")] [RequiredIf("customerTypeID", 4, ErrorMessage =

ASP.NET MVC 3 jQuery client validation - disable for specific button (Ajax form)

丶灬走出姿态 提交于 2019-12-11 08:29:48
问题 How can I disable validation for one button inside the Ajax begin form? Using jQuery validation I tried many ways from Google, but none of them worked ( class="cancel" , disableValidation attribute, etc.). 回答1: There may be other ways, but one for sure way is to remove all the validation rules if using unobtrusive validation via: http://docs.jquery.com/Plugins/Validation/rules#.22remove.22rules 回答2: $('#frmMyName').validate().cancelSubmit=true; 来源: https://stackoverflow.com/questions/6240898

Unobtrusive validation fails when a Checkbox is on the form

青春壹個敷衍的年華 提交于 2019-12-11 07:23:53
问题 I have a simple Login page that suddenly (After upgrading Jquery.js and Jquery-ui.js to 1.10.2 and 1.10.3 respectively) started to actually reach the action result instead of showing the client side validation messages defined on the E.F Data Annotations. So I found out that removing the only CheckBoxFor that I have besides the User and Password, the submit button actually works as it should be so that it raises client validations only without reaching the controller. Any reason for this

Jquery Validation Don't work on Submit if Submit has some Code

不想你离开。 提交于 2019-12-11 06:30:52
问题 I am using MVC Data Anotation with jquery validation for validating my form. It works perfectly on submit but if I write some code on submit click, it doesn't validate it. Why so? Where am I wrong? I am using jquery.validate.unobtrusive.min.js and jquery.validate.min.js I am not getting any kind of error. Just in my case, jquery validation stop working on submit if I put some code on submit click. HTML: <form action="/Login/ChangePassword" id="changePasswordForm" method="post"> <div id=

How to display validation errors on page load?

老子叫甜甜 提交于 2019-12-11 05:58:49
问题 I am creating a feature in my app to process an uploaded CSV file containing multiple records to be imported. Data needs to be validated, and I want to show any validation errors BEFORE the Import button is clicked. High-level plan: Step 1: Upload CSV file Step 2: Display all records from CSV file and any validation errors next to each record (missing required fields, etc.) Step 3: Click "Import" in order to actually import the valid records. Here's a simplified version of what I have: User

Asp.net Validation just working for one property

我的未来我决定 提交于 2019-12-11 04:34:06
问题 Following is my Model for Product public class Product { public int Id { get; set; } [Required(ErrorMessage = "Please Enter Product Name")] [StringLength(100)] public string Name { get; set; } [Required(ErrorMessage = "Please Enter Short Desciption")] [StringLength(200)] . // other properties . // Removed for brevity } And following is my View code <div class="contentHolder"> @using (Html.BeginForm()) { @Html.ValidationSummary(true) Html.Telerik().TabStrip() .Name("TabStrip") .Items(tabstrip

Jquery validation on matching 'password' and 'admin' not working [duplicate]

跟風遠走 提交于 2019-12-11 03:26:46
问题 This question already has answers here : Regular expression to match a line that doesn't contain a word (29 answers) Closed 4 years ago . I have tried to write a regular expression for passwords: public class ApplicationUser : IdentityUser, ITimeStamps { public const string PasswordRegularExpression = @"admin|password"; // public const string PasswordRegularExpression = @"/admin|password/i"; // Tried this too // public const string PasswordRegularExpression = @"/(admin|password)/i"; // Tried

Unobtrusive validation with dynamically loaded partial view

不问归期 提交于 2019-12-11 03:20:40
问题 I'm loading partail view on button click function loadview(ele) { if (ele == 'account') { $('#updateprofile').load('@Url.Action("UpdateProfile", "Account")'); $.validator.unobtrusive.parse($("#updateprofile")); } if (ele == 'password') { $('#changepassword').load('@Url.Action("ChangePassword", "Account")'); $.validator.unobtrusive.parse($("#changepassword")); } } Validation is not working on partial view loaded by ajax request. However it works with @Html.Partial("ChangePassword", Model

Validate other field without causing infinite loop

跟風遠走 提交于 2019-12-11 02:49:00
问题 I have a situation where I am creating an unobtrusive validator that must validate that another field is required only if the validated field is not empty (and vice versa). The problem is that there are some edge cases where the other field does not re-validate, and I would like to force it to revalidate itself without causing an infinite loop. My validation method looks like this: $.validator.addMethod("jqiprequired", function (value, element, params) { if (!this.optional(element) || (this

Regular expression is not matching new lines

北慕城南 提交于 2019-12-11 02:39:43
问题 I have the following reg ex: "^((?!([\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3})))).)*$" But it's not matching new lines as well: https://regex101.com/r/nT6wK0/1 Any ideas how to make it match when there is a new line? 回答1: The . at the and actually means All but a line break character. (source) By replacing it with [\S\s] , it means All spacing characters and all non-spacing characters; so all characters. Then it seems