SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    double check my validation please?

    I have several 'sets' of radio buttons that I want to validate before the form is actually submitted. So, I have this code here.
    Code:
    if ( ( document.PDC_Hotline.issue_radioset[0].checked == false )
    && ( document.PDC_Hotline.issue_radioset[1].checked == false )
    && ( document.PDC_Hotline.issue_radioset[2].checked == false )
    && ( document.PDC_Hotline.issue_radioset[3].checked == false )
    && ( document.PDC_Hotline.issue_radioset[4].checked == false )
    && ( document.PDC_Hotline.issue_radioset[5].checked == false )
    && ( document.PDC_Hotline.issue_radioset[6].checked == false )
    && ( document.PDC_Hotline.issue_radioset[7].checked == false )
    && ( document.PDC_Hotline.issue_radioset[8].checked == false )
    && ( document.PDC_Hotline.issue_radioset[9].checked == false )
    && ( document.PDC_Hotline.issue_radioset[10].checked == false )
    && ( document.PDC_Hotline.issue_radioset[11].checked == false )
    	&& ( document.PDC_Hotline.issue_radioset[12].checked == false ) )
    	{
    		alert ( "Please select an issue in the Issue section " );
    		return false;
    	} else {
    return true;
    }
    and this code here
    Code:
    if ( ( document.PDC_Hotline.resolution_radioset[0].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[1].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[2].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[3].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[4].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[5].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[6].checked == false )
    && ( document.PDC_Hotline.resolution_radioset[7].checked == false ))
    	{
    		alert ( "Please select an resolution in the Resolution section " );
    		return false;
    	} else {
    return true;
    }
    and the problem is that they both work perfectly fine apart, but when I put one right under the other one, in the same function, only the one on the top works. Am I missing a parenthesis or something?

  2. #2
    SiteP0int Weazle hooknc's Avatar
    Join Date
    Dec 2004
    Location
    Socialist Republic of Boulder
    Posts
    937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [rant]
    First off, it is insane to have such a huge if statement like that...


    Insane...
    [/rant]

    Anyways back to your question...

    Because there are return statements at the bottom of your if statements. So, no matter what you are returning from your if statement and the second if statement will never be reachable.

    Regards,

    Nate

  3. #3
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aw nutz, this is getting more complex. How um, would you recomend doing this to make it less huge?

  4. #4
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW FOLKS ... have we seen the notice at the top of this section that says

    this is NOT the javascript section!

  5. #5
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hahaha, if I saw that I wouldnt have posted here. Oh well, thanks for the help hooknc

  6. #6
    SiteP0int Weazle hooknc's Avatar
    Join Date
    Dec 2004
    Location
    Socialist Republic of Boulder
    Posts
    937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess I should try and at least work with Java Script.

    I can't even notice it when it is right in front of my face.



    Nate

  7. #7
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I take it you have moved the question then, as my eyes tell me different ( this is a javascript forum )

    either that or i'm a total numnut.

    Gav

  8. #8
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, but its already been answered. Thanks though.


Bookmarks

Posting Permissions

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