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
    Regular Coder
    Join Date
    Aug 2002
    Posts
    247
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with radio button validation

    Can someone help me??

    I have an asp form with 4 radio buttons and i want to have one button chosen before the form is submitted. I have this code snippet but if I do not check a button, the form still submits:
    <head>
    <SCRIPT language="JavaScript">

    function Validate() {

    if ((document.contest.Website.check == true) || (document.contest.Radio.checked == true) || (document.contest.Print.checked == true || (document.contest.Other.checked == true) {
    return true;
    }
    else {
    return false;
    }

    }

    </script>
    </head>

    <form method="post" action="contest.asp" name="contest" onSubmit="return Validate()">

    <input type="radio" value="1" name="q1>Website
    <input type="radio" value="1" name="q1">Radio
    <input type="radio" value="1" name="q1">Print Ad
    <input type="radio" value="1" name="q1">Other

    How do I get the form to give a message stating that a button needs to be checked and to not submit if a button is not checked??

    Can someone help me???

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try searching the forum. Radio button validation is an often asked and answered question and a search should return numerous results, any of which should provide the solution.

    .....Willy


  •  

    Posting Permissions

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