jquery-validate

jQuery Validate checkbox checked required?

给你一囗甜甜゛ 提交于 2019-12-18 04:47:07
问题 I'm using jQuery Validation plugin to validate a form. The problem is that I can't find a way to validate if a single checkbox in my form is checked HTML markup: <label for="terms">terms : </label> <input type="checkbox" name="terms" id="terms"> jQuery code: rules: { terms: "required" }, messages:{ terms: "check the checbox" } Any help would be appreciated. 回答1: Maybe your checkbox has css style display: none Replace it with visibility: hidden; width: 0; It helped to me. 回答2: HTML markup:

Single select options binding with jQuery validation is not working

寵の児 提交于 2019-12-18 04:45:12
问题 I am binding a list of objects to a select using knockout. Object Class can have any number of properties <select id="TheProperty_City" name="TheProperty_City" class="required" data-bind="options: cityList, optionsText: 'Name', value: selectedCity, optionsCaption: '--select the city--'" /> This works perfectly fine and I can use viewModel.selectedCity().Name or viewModel.selectedCity().Value for loading child elements. My issue is with jQuery validation. If I leave the statement as above,

jQuery Validate multiple fields with the same name

一世执手 提交于 2019-12-18 04:43:25
问题 I have this form with inputs with the same name but similar (incremental) ids. I want the form to validate if there is a name on person, the age must be mandatory.. What happens now is that only the first input is mandatory. Here is my code: <html lang="en"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script> </head> <body> <form id="people"> <div class

How can I disable/enable submit button after jQuery Validation?

与世无争的帅哥 提交于 2019-12-18 04:42:24
问题 I want to disable the submit button of the form after the "on_click" event, this jscript does it succesfully, but when a incorrect email is validated with jquery and then pressed the submit button, after I make the correction of the email, the button still is disabled. How can i solve this!? Jscript: <script src="js/libs/modernizr-2.6.2.min.js"></script> <script src="lib/jquery-1.11.1.js"></script> <script src="lib/jquery.js"></script> <script src="dist/jquery.validate.js"></script> <script>

jquery validate: sum of multiple input values

假装没事ソ 提交于 2019-12-18 04:39:13
问题 I need help to create custom method to validate sum of multiple text input values. In form I have variable number of text inputs and when submitting I need to validate that the sum of input values in same group is exactly 100. example (second group should not validate): <input type='text' name='g1_number1' class='group1' value='20' /> <input type='text' name='g1_number2' class='group1' value='40' /> <input type='text' name='g1_number3' class='group1' value='40' /> <input type='text' name='g2

jQuery Validation plugin: add/remove class to/from element's error container

£可爱£侵袭症+ 提交于 2019-12-18 04:36:08
问题 I'm working with the jQuery Validation plugin and I wrote the following code which adds a class to the element's ( <input> ) parent ( <label> ) if not valid, as well as inserting the actual error element ( <span> ) before the <br> . the HTML ... <label> text<br><input> </label> ... and the jQuery. $("#form_to_validate").validate({ rules: { ... }, errorElement: "span", errorPlacement: function(error, element) { element.parent().addClass('error'); error.insertBefore(element.parent().children(

ASP.NET LinkButton / ImageButton and JQuery Validate?

眉间皱痕 提交于 2019-12-18 04:35:08
问题 We are introducing JQuery to an existing ASP.NET application and use the Validate plugin for JQuery to do the client side validation (we do not want to use the asp.net validators). Everything works nicely with the asp:Button control. The client side validation is triggered before the page is submitted. However when using the LinkButton and ImageButton controls the page gets submitted without validating the form first. This is due to the fact that validate works with Buttons that are rendered

Group validation messages for multiple properties together into one message asp.net mvc

蓝咒 提交于 2019-12-18 03:58:29
问题 I have a view model that has year/month/day properties for someone's date of birth. All of these fields are required. Right now, if someone doesn't enter anything for the date of birth they get 3 separate error messages. What I want to do is somehow group those error messages together into 1 message that just says 'Date of birth is required'. So if 1 or more of those fields are blank, they will always just get the 1 validation message. I NEED this to work on client-side validation via jquery

adding jquery validation dynamically

痞子三分冷 提交于 2019-12-18 03:48:44
问题 I found where you can add jquery validation rules dynamically like this: $("#ParentAdNumber").rules("add", { required: true }); But how do you attach and detach a related message to it? 回答1: $("#ParentAdNumber").rules("remove", "required"); From the documentation: http://docs.jquery.com/Plugins/Validation/rules Edit: messages Adding: $("#ParentAdNumber").rules("add", { optionName: true, messages: { optionName: "message for optionName" } }); Removing: $("#ParentAdNumber").rules("remove",

jQuery Validation plugin display success/fail images next to password

牧云@^-^@ 提交于 2019-12-18 03:48:28
问题 I am using jQuery form validation using validation plugin. I have validate the password with minimum 7 characters and one capital and oe number.at the same time when i meet that the password is valid need to show the correct image near to the textfield. Otherwise wrong image. jQuery.validator.addMethod('mypassword', function(value, element) { return this.optional(element) || (value.match(/[A-Z]/) && value.match(/[0-9]/)); }, 'Password must contain at least one capital and one number.');