Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6842103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:03:28+00:00 2026-05-27T00:03:28+00:00

I am using below method for validating that one of radio button must be

  • 0

I am using below method for validating that one of radio button must be selected.

function validateForm(){
    var searchType = document.getElementsByName("form1:searchType");
    var a = !(searchType[0].checked);
    var b = !(searchType[1].checked);
    if(a&&b){
        alert('Please select search type');
        return false;
    }
    return true;
}

In above method searchType is radio button which is creating two buttons. It works fine that is shows alert message if none of the two radio buttons are selected but it show alert message even when second of the radio button is selected. Any idea please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:03:29+00:00Added an answer on May 27, 2026 at 12:03 am
    <html>
    <head>
    <script language="javascript">
    
    function validateForm(){
        var searchType = document.getElementsByName("form1:searchType");
        var a = !(searchType[0].checked);
        var b = !(searchType[1].checked);
        if(a&&b){
            alert('Please select search type');
            return false;
        }
        return true;
    }
    
    </script>
    
    
    </head>
    
    <body>
    
    <form name="form1">
    
    <input type="radio" name="form1:searchType" /> male
    <input type="radio" name="form1:searchType" /> female
    <input type="submit" name="submit" value="submit" onclick="validateForm()" >
    
    </form>
    
    </body>
    </html>
    

    i am using your function in this code and its working fine, it may help you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently i am creating an extension method that accepts parameters. Using the below example,
I'm using the below method to reply to mails coming in to a business
I have a class that I am using below. And I am using this
i want to implement next previous functionality using below function. - (void)motionEnded:(UIEventSubtype)mt withEvent:(UIEvent *)event
I am validating a zip code using Javascript that is generated server-side, and injected
I'm using the ChangePassword method of membership provider to change the password and one
I am validating a text box using javascript, now what happens is that if
Hi I'm using the below method to write to a file from the Jtextarea
i am using below code to change the the font type of text view.
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.