2

I have the following div block which i'm trying to validate using the jQuery validation plugin

<div class="row" id="signupaddress1" hidden>
    <label for="id-31"><span>Address 1:</span><span class="mark">*</span></label>
    <input type="text" class="required" id="id-31" name="address1"/>
</div>

Then using

$("#form").validate(...); 

to validate the form. But if this div is hidden it appears to ignore the field when validating. The form uses a postcode lookup to populate the address fields and then displays the div when this has been populated but, as a result, if only the postcode is entered the form can be submitted without validating address1 contains anything.

2
  • Possible duplicate of stackoverflow.com/questions/2623514/… Commented Jan 12, 2012 at 12:01
  • Nope that's the opposite of the problem. It appears not be be validating and this option hasn't been set on the plugin. Commented Jan 12, 2012 at 12:54

2 Answers 2

4

I guess you are using the new validator plugin which ignores hidden fields by default. To overwrite that just use this and it will work.

ignore:""

You can refer to the Github repo for the change Changeset

Sign up to request clarification or add additional context in comments.

Comments

0

You are telling jQuery to validate the form but where is your form tag you should do something like this

<form><div class="row" id="signupaddress1" hidden>
<label for="id-31"><span>Address 1:</span><span class="mark">*</span></label>
<input type="text" class="required" id="id-31" name="address1"/></div></form>

than use

$("form").validate(...); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.