Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery validate interdependent PAIR of FIELDS
    primarykey
    data
    text
    <p>I need to validate a set of name , mobile number fields in a form. For convenience on the serverside script, I've named the fields with array notation (i.e., with square brackets). Also, the same html below repeats itself a number of times depending on how many records are required.</p> <pre><code>&lt;table width="100%" border="0"&gt; &lt;tr&gt;&lt;td class="b_name"&gt;&lt;label&gt;Name &lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;&lt;/td&gt;&lt;td class="b_mobile"&gt;&lt;label&gt;Mobile &lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;&lt;/td&gt;&lt;td class="removetext"&gt;&lt;a href="javascript:void(0);" onclick="removebroadcast(this);" id="remove_&lt;?php echo $cnt;?&gt;"&gt;Remove&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td class="b_name" id="name_&lt;?php echo $cnt;?&gt;"&gt;&lt;input type="text" value="" name="broadcast_name[]" class="broadcast_name" /&gt;&lt;/td&gt;&lt;td class="b_mobile" id="mobile_&lt;?php echo $cnt;?&gt;"&gt;&lt;input type="text" value="" name="broadcast_mobile[]" class="broadcast_num" /&gt;&lt;/td&gt;&lt;td id="message_&lt;?php echo $cnt;?&gt;"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p>On the rules/messages part so far, I've come up with:</p> <pre><code>'broadcast_name[]':{required:function(element){ return $(element).parent().next().children('input').val()!=''; } }, 'broadcast_mobile[]':{required:function(element){ return $(element).parent().prev().children('input').val()!=''; } }, </code></pre> <p>However, this does only work for the first set of name / mobile fields. I tried a few other tricks too (e.g., used $.each type validation, used a custom rule function etc.) but none of them seemed to work. Is there anything I am doing wrong here? Please help! :(</p>
    singulars
    1. This table or related slice is empty.
    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.
    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