jquery-validate

jQuery validation date range issue

独自空忆成欢 提交于 2020-01-13 10:21:47
问题 I have a number of spots in my code where I have pairs of related start and end date fields (range). I need to validate that the start is before the end date. I'm using the jQuery validation plugin. Here's my code: http://jsfiddle.net/jinglesthula/dESz2/ Markup: <form id="myform"> <input type="text" name="startDate" id="startDate" class="validDate" /> <br/> <input type="text" name="endDate" id="endDate" class="validDate" /> <br/> <input type="submit" /> </form> js: $(function() { // simple

Validate a Hidden Field

…衆ロ難τιáo~ 提交于 2020-01-12 01:26:53
问题 I'm using MVC3 with unobtrusive validation. I have a field that the user is expected to fill with some data and then press a "search" button. If search has never been pressed or the user has changed the input field after pressing search, the form should not be possible to submit. I've added a hidden field that is set to true by the click() event of the button and emptied by the keyup() event of the input box. Now I would like to add a validation rule that requires the hidden field to be true

How to extend jquery.validate URL validation?

笑着哭i 提交于 2020-01-11 19:52:56
问题 I have a need for users to be able to create partial URLs without needing to type the full URL each time. For example, say I plan on the url being www.example.com/areas/{userinput}/home . I want the user to be able to enter some text in a text box and I want to validate that it is a valid URL. The URL validator functions like this: url: function(value, element) { return this.optional(element) || /giantregex/.test(value); } I've attempted adding a validation method to the validator via the

How can I clone a fieldset without keeping the rules of the fields?

吃可爱长大的小学妹 提交于 2020-01-11 14:27:07
问题 I cloned my fieldset and it works perfect. I clear all fields value perfectly. The only issue I'm having is the rules follow if submit had been hit before adding the new fieldset and no if you haven't hit on submit. What I really want is to be able to either remove all the rules and set it up again or keep the rules in a way they work properly. I tried to remove the rules and it didn't work (). I tried adding new rules, it works but I have 1 more rule for each field every time I add a section

How to validate input, in non-form element, on keyup with jQuery validate plugin

回眸只為那壹抹淺笑 提交于 2020-01-11 13:16:11
问题 I have a site that is being built in ASPX. Unfortunately, because of this fact, I cannot actually use the <form> tag to wrap my inputs, and as far as I can see, jQuery Validation Plugin only supports validating inputs within a <form> . Is there any way to validate these inputs, using the specified rules, on keyup without having them wrapped in a <form> tag? $(function() { $('.form-container').validate({ rules: { useremail: { required: true, email: true }, userstate: { required: true,

jQuery turn off form validation

丶灬走出姿态 提交于 2020-01-11 10:44:12
问题 Im using the bog standard form validation plugin. I have two radio buttons 'yes' 'no' and what im trying to do is set validation if a radio 'yes' is checked... Which works, but i need to then turn off validation if the 'no' radio is selected. Im trying the following... <script type="text/javascript"> $(document).ready(function() { $('.cbyes').click(function() { $('.hiddenDiv').show('slow'); $("#regForm").validate(); }); $('.cbno').click(function() { $('.hiddenDiv').hide('slow'); $('#regForm')

jQuery turn off form validation

本小妞迷上赌 提交于 2020-01-11 10:43:15
问题 Im using the bog standard form validation plugin. I have two radio buttons 'yes' 'no' and what im trying to do is set validation if a radio 'yes' is checked... Which works, but i need to then turn off validation if the 'no' radio is selected. Im trying the following... <script type="text/javascript"> $(document).ready(function() { $('.cbyes').click(function() { $('.hiddenDiv').show('slow'); $("#regForm").validate(); }); $('.cbno').click(function() { $('.hiddenDiv').hide('slow'); $('#regForm')

JQuery validate plugin - can't validate classes

此生再无相见时 提交于 2020-01-10 20:00:54
问题 I'm trying to use the jQuery validate plugin to validate classes instead of ID's. Despite the many threads which seem close to answering this issue - I can't get any of them to work. I simply have a form that has a lot of dynamically generated repeating form fields, so naturally I can't add rules for the ID's because there's no knowing how many of them there will be. So, instead, I would like to just target the class on the input field. <input type="text" id="name1" class="fileName" /> <input

JQuery validate plugin - can't validate classes

做~自己de王妃 提交于 2020-01-10 20:00:12
问题 I'm trying to use the jQuery validate plugin to validate classes instead of ID's. Despite the many threads which seem close to answering this issue - I can't get any of them to work. I simply have a form that has a lot of dynamically generated repeating form fields, so naturally I can't add rules for the ID's because there's no knowing how many of them there will be. So, instead, I would like to just target the class on the input field. <input type="text" id="name1" class="fileName" /> <input

Display both summary and individual error messages using the jQuery validation plugin

老子叫甜甜 提交于 2020-01-09 13:10:07
问题 How can I display both individual error messages and summary for the jQuery plugin? I actually found a similar question , but it just references some hooks I can use, but I'm not sure where to start. I got the displaying individual error messages part, but I need to display the summary in an alert box on submit, and plugin can be found here. Just found out how, thanks for David's code, and on my follow-up question - The alert box would be "First Name: Please enter a valid First Name". Code