Results 1 to 2 of 2

Thread: onsubmit select one radio button only

  1. #1
    Join Date
    Jul 2008
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post onsubmit select one radio button only

    Hi.......
    In my code i have 5 radio buttons.
    I need to validate that the user should select one radio button only, during submission.If user clicks 3 radio button and give submission means,it must give me a alert message and do not submit.
    I need a sample code to for my above logic.

    regards
    satheesh kannan

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    If you give all of the radios the same name, it will only let the user select one radio.
    For example:
    HTML Code:
    <input type="radio" name="food1" value="food1" /> Corn<br />
    <input type="radio" name="food2" value="food2" /> Pizza<br />
    <input type="radio" name="food3" value="food3" /> Steak<br />
    You can select more then one. But with:
    HTML Code:
    <input type="radio" name="food" value="food1" /> Corn<br />
    <input type="radio" name="food" value="food2" /> Pizza<br />
    <input type="radio" name="food" value="food3" /> Steak<br />
    You can only select one.
    Jeremy | jfein.net

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
  •