Javacript Tweak

Posted on 2012-09-12
Last Modified: 2012-09-26

I'd appreciate some help with tweaking a javascript validation script --

function validateBrandRate(formNode){
  var formValidatorInstance = new FormValidator(formNode);
  formValidatorInstance.addRule('nextyearreason','Please indicate why you will not deal with this brand next year','required');
  return formValidatorInstance.validate(); 

Open in new window

I need the script to run only if a checkbox with an ID of sliderLabel is checked.

At the same time, if the checkbox with an ID is checked I need the select with an id of nextyearreason to be enabled; and disabled if the checkbox is not checked.

I think this is two different scripts, an alteration to the first one and a new script for the enable disable.

Thank you
Question by:garethtnash
    LVL 49

    Accepted Solution

    Take a look at the docs here

    Specifically this section:
    Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contacting via email.
       rules: {
         contact: {
           required: true,
           email: {
             depends: function(element) {
               return $("#contactform_email:checked")

    Open in new window


    Author Closing Comment

    Thank you

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now