Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: How to validate Radio buttons?

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How to validate Radio buttons?

    I need to validate radio buttons using an alert box. It also needs to work in conjunction with another validation how is this done? How do you validate a radio button? How do you validate?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,285
    My Mood
    Mellow
    Thanks
    252
    Thanked 777 Times in 762 Posts

    Default Re: How to validate Radio buttons?

    Validating might be as simple as asking the user, "Are you sure?" with OK/Cancel buttons to more complicated verifications to determine that the choice is "legal" and executable according to program logic and what could happen next.

    In my experience, radio buttons are typically low-level logic, not by themselves causing significant things to happen, so I'm curious why validation is even required. Perhaps you could give more detail.

  3. The Following User Says Thank You to GregBrannon For This Useful Post:

    learning2code (December 17th, 2013)

  4. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: How to validate Radio buttons?

    Validation is required to ensure that a radio buttons have been selected and that the selected button is the correct one.

  5. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,285
    My Mood
    Mellow
    Thanks
    252
    Thanked 777 Times in 762 Posts

    Default Re: How to validate Radio buttons?

    There are methods available to determine if a radio button has been selected. Look at both the radio button and button group classes to find the method you need for that part. As for the second part, to determine if the selected button is correct, that would involve whatever logic is required to determine correctness, something you haven't explained. Frankly, give the user a break and gray out radio buttons that aren't "correctly" selectable.

  6. #5
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    646
    My Mood
    Sleepy
    Thanks
    10
    Thanked 95 Times in 88 Posts

    Default Re: How to validate Radio buttons?

    Greg, this is about javascript. See the OP's other thread.

  7. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,285
    My Mood
    Mellow
    Thanks
    252
    Thanked 777 Times in 762 Posts

    Default Re: How to validate Radio buttons?

    Ahhh. Thanks.

  8. #7
    Junior Member
    Join Date
    Nov 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to validate Radio buttons?

    syntax to create radiobutton when you using applet
    CheckBoxGroup x=new CheckBoxGroup();
    add(new Checkbox("male",x,true);

Similar Threads

  1. Function and radio Buttons in JAVA
    By learning2code in forum Other Programming Languages
    Replies: 7
    Last Post: December 17th, 2013, 07:32 AM
  2. Button and Radio Buttons not working!!!
    By rokere1 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 19th, 2013, 04:59 PM
  3. Help with radio buttons and results.
    By Bewitched1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 3rd, 2011, 04:01 PM
  4. radio buttons stop working
    By tabutcher in forum AWT / Java Swing
    Replies: 2
    Last Post: March 5th, 2010, 09:28 AM
  5. [SOLVED] Using html Radio Buttons with Servlets
    By oss_2008 in forum Java Servlet
    Replies: 2
    Last Post: June 25th, 2009, 06:39 AM