Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting conditional rule using jQuery validation
    text
    copied!<p>Hi I have a simple modal popup which has 3 name fields and 3 e mail fields adjacent to each other. I am new to jQuery so can any one please help me how to write a logic for the following case?</p> <p>The first name field and Email field are mandatory so I kept the class as required fields but the other two name and e-mail fields are optional but if I enter a value in name field I have to enter the value in Email field. In other words if name field is not empty email field should not be empty. Please let me know if some one can help me thank you.</p> <pre><code>&lt;div class="leftCol"&gt; &lt;label for="emailToName1" class="formLabel"&gt;&lt;span class="required"&gt;*&lt;/span&gt;Name:&lt;/label&gt; &lt;div&gt;&lt;input type="text" id="emailToName1" name="referName01" value="${referAFriendBean.referName01!}" class="required" tabindex="1" /&gt;&lt;/div&gt; &lt;div class="pad5Top"&gt;&lt;input type="text" id="emailToName2" name="referName02" value="${referAFriendBean.referName02!}" tabindex="3" /&gt;&lt;/div&gt; &lt;div class="pad5Top"&gt;&lt;input type="text" id="emailToName3" name="referName03" value="${referAFriendBean.referName03!}" tabindex="5" /&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="rightCol"&gt; &lt;label for="emailToAddress1" class="formLabel"&gt;&lt;span class="required"&gt;*&lt;/span&gt;Email address:&lt;/label&gt; &lt;div&gt;&lt;input type="text" id="emailToAddress1" name="referEmail01" value="${referAFriendBean.referEmail01!}" class="required email" tabindex="2" /&gt;&lt;/div&gt; &lt;div class="pad5Top"&gt;&lt;input type="text" id="emailToAddress2" name="referEmail02" class="email" tabindex="4" value="${referAFriendBean.referEmail02!}" /&gt;&lt;/div&gt; &lt;div class="pad5Top"&gt;&lt;input type="text" id="emailToAddress3" name="referEmail03" class="email" tabindex="6" value="${referAFriendBean.referEmail03!}" /&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&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