Hello and welcome to our community! Is this your first visit?
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
    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;
    alert("Please select an answer.");
    return false;
    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. #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Thanked 257 Times in 253 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