Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Assuming that you are using the jQuery <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">validation plugin</a>, you could set/clear the class of each of the controls in the required/not required sections based on the checkbox that was clicked. </p> <pre><code>$(document).ready( function() { $('form').validate(); } ); function init_validation(divName) { $('div#' + divName).find('input').addClass( 'required' ); $('div#inputs').children('div:not(#' + divName + ')') .find('input') .removeClass( 'required' ); } </code></pre> <p>HTML:</p> <pre><code>&lt;form&gt; &lt;div&gt; &lt;input type='radio' id='new_account_radio' name='interface_selector' value='new_account' selected=true onclick='init_validation("new_account");' /&gt; New Account &lt;input type='radio' id='delete_account_radio' name='interface_selector' value='delete_account' onclick='init_validation("delete_account");' /&gt; Delete Account &lt;input type='radio' id='new_software_radio' name='interface_selector' value='new_software' onclick='init_validation("new_software");' /&gt; New Software &lt;/div&gt; &lt;div id='inputs'&gt; &lt;div id='new_account'&gt; &lt;input type='text' id='new_account_name' class='required' /&gt; &lt;/div&gt; &lt;div id='delete_account'&gt; &lt;input type='text' id='delete_account_name' /&gt; &lt;/div&gt; &lt;div id='new_software'&gt; &lt;input type='text' id='new_software_name' /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
 

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