Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Validation Plugin Name Conflict with Zend_Form
    primarykey
    data
    text
    <p>By default, Zend_Form creates a hidden input field for each checkbox input in the form. These inputs share the same name.</p> <pre><code>&lt;input type="hidden" name="zend-cb" value=""&gt; &lt;input type="checkbox" name="zend-cb" id="zend-cb" value="1"&gt; </code></pre> <p>I want to require the checkbox, so I set up the following rule in my jquery plugin validator (<a href="http://bassistance.de/jquery-plugins/" rel="nofollow noreferrer">http://bassistance.de/jquery-plugins/</a>):</p> <pre><code>'zend-cb': { required: true } </code></pre> <p>Unfortunately, the Jquery Validation plugin always validates the hidden field instead of the checkbox. Is there a way I can have it validate the checkbox instead? I realize I could change my Zend Decorator to omit the hidden field, but I'd like to find a pure javascript solution.</p> <p><strong>Solution</strong></p> <p>Two steps are needed to get around this problem.</p> <p>1) Add ignore: "input[type=hidden]" as an option to the validate method.</p> <pre><code>$('#myForm').validate( { ignore: "input[type=hidden]", rules: { ... } } </code></pre> <p>2) Open jquery.validate.js and update the findByName method to use the ignore filter. Bug report filed by adamnfish on the jquery plugin site.</p> <p><a href="http://plugins.jquery.com/node/9234" rel="nofollow noreferrer">findByName does not honour ignore settings</a></p> <pre><code>findByName: function( name ) { // select by name and filter by form for performance over form.find("[name=...]") var form = this.currentForm; return $(document.getElementsByName(name)).not(this.settings.ignore).map(function(index, element) { return element.form == form &amp;&amp; element.name == name &amp;&amp; element || null; }); }, </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload