SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating Multiple Button Sets

    Oops .. I should have mentioned in title these are RADIO button sets ...


    I have 3 sets of radio buttons all in one form. (I am working with paypal.) I have found a script that can check to make sure that the first group (paypal.os0) is checked - but then when I try to add code for the other 3 sets
    (paypal.os1 and paypal.os2) the code breaks.

    I have pulled out my attempts to add the next two sets - here is the code with only one. Can someone steer me in the right direction of how I would add the next two groups? Thanks much.


    Code JavaScript:
    <script language="JavaScript1.2" type="text/javascript">
     
     
    function valbutton(paypal) {
    // place any other field validations that you require here
    // validate myradiobuttons
    myOption = -1;
     
     
     
    for (i=paypal.os0.length-1; i > -1; i--) {
    if (paypal.os0[i].checked) {
    myOption = i; i = -1;
    }
    }
     
     
    if (myOption == -1) {
    alert("You have not finished chosing your options");
    return false;
    }
     
     
    // place any other field validations that you require here
    thisform.submit(); // this line submits the form after validation
    }
     
    </script>

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have an example of the markup you are using and what you are actually passing into the JS function?


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
  •