Bassistance validation plugin

Bassistance validation plugin

Thanks in advance for your help!

I have a form which successfully uses the  bassistance validation plugin to highlight required fields.

Currently all fields with class="required error" are set to always flag as required if no data entered (mainly textarea fields)

The requirement now is for some questions which have a yes/no radio button. If user selects Yes the textarea asking for more information needs to be available and a required field, if user selects No this is not required.

Having scoured around the web I have come up with the following:

HTML CODE:

  1. <form onsubmit="return submitIt3(this)" action="step-2" method="post" name="form1" id="form1" novalidate="novalidate">

  2. <ol>

  3. <li>
  4. <span class="form-title"><strong>Question 1</strong></span><br>
  5. <input type="radio" name="screen_184" value="Yes" checked> 
  6. <label>Yes</label> 
  7. <input type="radio" name="screen_184" value="No"> 
  8. <label>No</label>
  9. <br><br>
  10. <textarea class="required error" maxlegth="500" name="screentext_184"/></textarea></li>
  11. <label for="screentext_184" generated="true" class="error">This field is required.</label>
  12. </li>

  13. <br><br>

  14. <a href="javascript:history.back()">
  15. <img class="button" src="img/back.jpg" height="30" width="72"></a>
  16. <img src="img/peaks.jpg" class="peaks">
  17. <input class="button" name="next-button" value="submit" type="image" src="img/next.jpg" height="30" width="72">

  18.   
  19. </ol>
  20. </form>

I need to know how/where to edit the code in js to get this working.
Where/how should i add this code in the jquery.validate.js file

JS CODE:

  1. $(document).ready(function () {

  2.     $('#form1').validate({ // initialize the plugin
  3.         rules: {
  4.             "screentext_184": {
  5.                 required: {
  6.                     depends: function (element) {
  7.                         return $("input[name='screen_184'][value='Yes']").is(":checked");
  8.                     }
  9.                 }
  10.             }
  11.         },
  12.         submitHandler: function (form) { 
  13.             alert('valid form submitted'); 
  14.             return false; 
  15.         }
  16.     });

  17. });

Thanks again