jquery validate input but use id for indentifying fields

I have fields in following format:

<input type="text" name="cities[]" id="city_zip1"/> <input type="text" name="cities[]" id="city_zip2"/> <input type="text" name="cities[]" id="city_zip3"/>

Is there a way to make first one required by validate plugin, but to leave name as it is? Or to make one of these three required, but to leave name as it is.

-------------Problems Reply------------

Done on click for example. Can be done on submit.

$("#checkforvalue").click(function(e) {
if ($("input#place_of_services:checked").val()) {
var zipentered = false;
$("input[id^='city_zip']").each(function() {
if ($(this).val().length) {
zipentered = true;

if (zipentered) {
alert("value in one of the fields");
} else {
alert("no value entered");

js fiddle example

Category:jquery Views:1 Time:2011-08-23

Related post

  • Jquery Validate - Input Mask Conflict 2012-02-20

    I have a form that uses jquery validate and the form validates on submit and on blur (onfucusout). Some of my fields have masks using the jquery mask plug in. The mask will place something like this in the field (---)---/---- when it comes into focus

  • JQuery Validate Input with certain class 2012-02-21

    I'm trying to validate input fields when the value is empty. I want to only target input fields using a certain class. I have tried to use .hasClass("required") without any success. I hope somebody can help. EDIT = Should of pasted the rest. --------

  • jQuery Validate: Display group error message until all fields are correct 2013-10-17

    I have grouped two input fields so that it only displays one error message regardless of how many of the input fields are invalid. My problem occurs if I leave both of them empty and try to submit the form - as soon as I enter anything into one of th

  • JQuery Validate Plugin - How to verify if all fields of a Form are numeric 2011-04-12

    I have a form with 10 fields to be verified as numeric, I would like to validate all the fields as numeric but I don't want to do something like: #field:{number:true} to all the fields. Adding a "Custom Method" or addClassRules would be the fast solu

  • jquery validate form input if certain check boxes are checked 2008-11-18

    I have a multipart form that takes basic user information at the beginning with some jquery.validate error checking to see if the fields have been filled in and the email address is valid. Below that there is a series of check boxes (type_of_request)

  • How to get jQuery validate success function to operate on a hidden input field? 2010-07-20

    I have a form being validated by jQuery.validate. Using errorPlacement option I have a custom set of functions for real-time error validation. Using success option I have a custom set of functions to get rid of and replace error messages. All works g

  • Conflict between jQuery Validate and Masked Input 2010-12-09

    I've got a form that's using both jQuery Validate and Masked Input for phone number and US zip code fields. For example, for a US zip code, Masked Input allows only numbers to be entered, and forces either the format "99999" or "99999-9999" (where 9

  • how to add multiple rules with different handling on a field with jquery validate 2010-07-13

    how do i add Form validation, with multiple rules on a single textfield, and a different action depending on the rule for example, a faq module, with pre-defined questions, the user can save and / or publish his answers. i have a form, with 1 textare

  • jquery Validate - Custom validation at runtime 2011-08-12

    In my form i have two text boxes txtName & txtAge . I use jquery.validate.js to make it as required field validator and it is working fine. Now my requirement is sometimes based on some business logic i need to make these 2 fields non-mandatory p

  • how to customize the position of the error message for each field from jquery validate plugin 2010-10-12

    I am using the jquery validate plugin, in combination with some custom field types (custom select boxes) default behaviour of the jquery validation plugin is to insert the error message element, right after the form element. though that would render

  • jQuery validate plugin clearing file input value in IE 2008-12-09

    Im currently using this jQuery validate plugin and having an issue in IE where its removing the value of file input fields whilst validating the rest of the form. This seems to me like an onfocus issue, I select a file to upload, click on another inp

  • jQuery validate plugin - validate rule across several input fields 2010-07-17

    I have a bunch of fields like so created on the fly <input type="text" name="coeff_a"> <input type="text" name="coeff_b"> <input type="text" name="coeff_c"> .. and so on .. I want to validate the input to the above fields, and am us

  • How do I remove the 'required' rules from all form inputs in jQuery Validate? 2010-07-23

    As above, how can I remove all of the required rules from a form using jQuery Validate? This is what I have at present: var settings = $('form').validate().settings; //alert(settings.rules.toSource()); for (var i in settings.rules){ alert(i); delete

  • Text inputs with maxlength not validating with jQuery Validate 2010-07-29

    I'm stuck with a problem using jQuery Validate. The thing is I have a few textboxes with their maxlength attributes set. Although they are not required, they still fail to validate when either empty or whitespace. Sample HTML: <input type="textbox

  • jQuery Validate() Hightlight Error Input Fields 2010-10-04

    I am using the jQuery Validate() plugin. It's been working just fine, however, I would like to Hightlight the input that has the error in it AFTER SUBMIT. I have tried the: $(".selector").validate({ highlight: function(element, errorClass, validClass

  • jquery validate plugin - How avoid from user insert white-spaces in input 2011-02-01

    How avoid from user insert white-spaces in ? (I use jquery.validate.js plugin) Example: input not possible(because user not able insert white-spaces): John Pitt My input possible:JohnPittMy Edit: use of regex in this case mistake - should be used onl

  • jQuery validate dynamicly added inputs 2011-05-05

    I use jQuery validate to validate a bunch of forms on a site that I'm working on. On this site I clone some inputs depending on a SELECT option selection. I want to validate these inputs, but when I do, only the first one gets validated. I tried to p

  • Using jQuery validate with HTML5 email input fields 2011-06-09

    I'm trying to validate a <input type="email"> using the jQuery validate plugin and the actual validation works fine, but it appears that if incorrect value has been entered and an error message appears, the error message remains after the error

  • jQuery Validate property 'max' isn't working on my input field 2011-06-20

    I have an input that I want to set the max value to 255. I'm not submitting the form, but rather calling a function which submits the data via ajax. Some of the other validate checks are working, like required and digits, but max isn't working. I'm u

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.109 (s). 11 q(s)