SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    radio button form validation

    if (document.AddProduct.frmProductCategory.value == ""){
    errorMsg += "\n\tRadio \t- Lütfen şifre hanesini doldurun.";
    }


    I have three radio buttons and i want at least one of them must be selected. I am using the above code to validate other form lements. how can i validate whether one of the radio buttons has been selected.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice font color.
    Code:
    .....................
    var inputgrp = document.AddProduct.frmProductCategory;
    var idx = inputgrp.length - 1;
    do
    	if (inputgrp[idx].checked)
    		break;
    while (idx--);
    if (idx < 0)
    	errorMsg += "\n\tRadio \t- Lütfen sifre hanesini doldurun.";
    .....................
    ::: certified wild guess :::


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
  •