Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery textarea validation with radio button
    primarykey
    data
    text
    <p>I am developing a survey system.</p> <p>table answer: field :<code>id, answer, answer_value, valdt.</code></p> <p>if answer=(please specify the time in the comments box) i put the value in valdt=1 otherwise its 0. </p> <p>whatever if surveyor click this radio button the comment box text is required.</p> <p>my code for the radio button is</p> <pre><code>$n1=$db-&gt;get_results("SELECT * FROM question where client='$client' and status='1' order by `id`"); foreach($n1 as $n2) { $s1=$db-&gt;get_results("SELECT * FROM answer where qid='$n2-&gt;id' "); foreach($1 as $s2) { &lt;input type="radio" name='ans[&lt;?php echo $s2-&gt;id?&gt;]' value="&lt;?php echo $s2-&gt;id?&gt;" validate="required:true" /&gt; } Comments:&lt;textarea rows="5" cols="30" name="cmnt[&lt;?php echo $n2-&gt;id?&gt;]" &gt;&lt;/textarea&gt; } </code></pre> <p>I want to validate if user clicks the radio button ( valdt=1 ) then the corresponding comment box text should be required, otherwise not.</p> <p>I tried to solve this but alert message trigger but wont validate the comment field I put the code inside the validation field but it wont work </p> <pre><code>$(document).ready(function() { $("#form1").validate(); function getNum(element, attrPrefix) { var prefix = attrPrefix; var num = element.attr("id").substring((prefix.length)); return num; } $(":radio").change(function() { var num = getNum($(this), "r_"); if ($("#r_"+num).not(":checked")) { alert(' Please Enter the comment in comment box '); } else { alert(' Please Enter Comment in Comment Box '); return false; } return true; }); </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.
 

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