title: how to use if rule in jquery
body: <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>
  
  <p><strong>The jQuery code is as follows its getting data from ajax</strong></p>
  
  <pre><code>function shareWithAFriend(itemId) {
          $.ajax({
              url: "shareWithAFriend.do?itemId="+itemId,
              type: "GET",
              success: function(html) {
                  $("#tellInfoPop").html(html);
                  $("#itemId").val(itemId);
                  $("#emailFriend").validate({
                      errorClass: "formError",
                      errorContainer: "#referAFriendFormError",
                      errorLabelContainer: "#referAFriendFormError",
                      onfocusout: false,
                      wrapper: 'li',
                      messages: {
                          referName01: {
                              required: "&lt;@spring.message "referAFriend.error.nameRequired"/&gt;"
                          },
                          referEmail01: {
                              required: "&lt;@spring.message "referAFriend.error.emailRequired"/&gt;",
                              email: "&lt;@spring.message "referAFriend.error.emailFormat"/&gt;"
                          },
                          referEmail02: {
                              email: "&lt;@spring.message "referAFriend.error.emailFormat"/&gt;"
                          },
                          referEmail03: {
                              email: "&lt;@spring.message "referAFriend.error.emailFormat"/&gt;"
                          },
                          securityKey: {
                              required: "&lt;@spring.message "referAFriend.error.securityRequired"/&gt;"
                          }
                      },
                      groups: {
                          emailGroup: "referEmail01 referEmail02 referEmail03"
                      },
  </code></pre>
  
  <p>THE Html code is as fallows</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>