php - Radio button text area -


i have survey form works fine. need 1 question changed. there's 2 radio buttons answers "yes" , "no" , text area under them. want text area locked unless user selects "yes" radio button can type in text area reason "yes".

i did looking around , attempting function doesn't seem working.

<script>    function validate() {      var radioyes = document.getelementbyid('radioyes');      var textarea = document.getelementbyid('question5comment');        if (radioyes.checked && question5comment.value.length < 1) {        alert('please enter reason question 5.');        question5comment.focus();        return false;      }    }      function toggle(value) {      document.getelementbyid('question5comment').disabled = value;    }  </script>    5. using other non-franchise service centres?   <br>  *if yes there other reason other price  <br>  <input type="radio" name="question5"         value="yes" required>yes  <br>  <input type="radio" name="question5"         <value="no" required>no   <br>  <textarea name="question5comment"  rows="5" cols="40" required></textarea>

your syntax wrong:

  1. unnecessary < before value.
  2. no ids referring in code.
  3. syntax errors.

use following:

function validate() {    var radioyes = document.getelementbyid('radioyes');    var textarea = document.getelementbyid('question5comment');      if (radioyes.checked && question5comment.value.length < 1) {      alert('please enter reason question 5.');      question5comment.focus();      document.getelementbyid('question5comment').disabled = true;      return false;    } else {      document.getelementbyid('question5comment').disabled = false;    }  }
5. using other non-franchise service centres?  <br>*if yes there other reason other price  <br>  <input type="radio" name="question5" value="yes" required onclick="validate();" id="radioyes" />yes  <br>  <input type="radio" name="question5" value="no" required onclick="validate();" id="radiono" />no  <br>  <textarea name="question5comment" id="question5comment" rows="5" cols="40" required></textarea>


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -