Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript jquery for verification

    Hello, I am trying to verify a form that has multiple check boxes, and when the "other" check box is checked and the "other_text" input has nothing in it, I need an error to fire asking to input the other text.. here is the current verification that does not work with my "other" check box.

    }else if(question_pos==24){

    if((!$('#followup_six_45_physician').prop('checked') && !$('#followup_six_45_pharm').prop('checked') && !$('#followup_six_45_nurse').prop('checked') && !$('#followup_six_45_none').prop('checked') && !$('#followup_six_45_other').prop('checked')) ||
    ($('#followup_six_45_other').prop('checked') && $('#followup_six_45_other_text').val() == "" )){

    if(( $('#followup_six_45_other').prop('checked') && $('#followup_six_45_other_text').val() == "")){
    alert("You selected \"Other\" for race, please fill in what other race you consider yourself to be.");
    return false;
    }else{
    alert("Please select an answer.");
    return false;
    }
    }else{
    question_pos+=1;
    showContent(question_pos,"right");
    progress(93, $('#progressBar'));
    return true;
    }


    So far, I get an error when the other checkbox is checked, but when I add text to the input, the error still fires. I dont know what to do to make the error only fire when there is no text in the "followup_six_45_other_text" and the "followup_six_45_other" is checked.

    Any help would be appreciated, for I am completely stuck right now.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Did you mean the alert message "You selected Other for race..." still appears even when the followup_six_45_other is checked and followup_six_45_other_text is not empty?

    Btw, please enclose the code in [code] [/code] tags for code readability.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •