perfect code to validate at least one radio button is selected

by biya on July 23rd, 2010

call this function on on click event,in else the other function is called

Syntax: JavaScript
Show lines - Hide lines - Show in textbox - Download
function valbutton(form) {
// place any other field validations that you require here
// validate myradiobuttons
myOption = -1;
for (i=form.rbt_no.length-1; i>-1; i--) {
if (form.rbt_no[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select an option to proceed");
return false;
}
else
 
 
{
 
 
next_ques('next');
 
 
}
html:
onclick="<?php /*?>next_ques('next')<?php */?> valbutton(form);return false;"
 
 
 

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS