Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Closed Thread
 
LinkBack Thread Tools
Old April 22nd, 2004, 12:49 AM   #1
New Member
 

Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 augustus_emperor is on a distinguished road
problem with radio button in form validation

I have a multi-field that consist of text, radio button and select field but the main prob is when it goes to radio button and i tried to submit it, the validation for radio button doesn't work... So can you check this coding and what is wrong with it???


<SCRIPT LANGUAGE=JAVASCRIPT>
function validate(form) {
//Data validation using object names to
// reference objects

if (form.user_name.value == "") {
alert("You must enter a User Name");
form.user_name.focus()
return false;
}

if (form.password.value == "") {
alert("You must enter a Password");
form.password.focus()
return false;
}

if (form.password.value != form.confirmpassword.value) {
alert("Password and Password Confirmation Did Not Match");
form.confirmpassword.focus()
return false;

}

if (form.first.value == "") {
alert("You must enter a First Name");
form.first.focus()
return false;
}

if (form.last.value == "") {
alert("You must enter a Last Name");
form.last.focus()
return false;
}

if (form.age.value == "") {
alert("You must enter Age");
form.age.focus()
return false;
}

if (form.dob.value == "") {
alert("You must enter your birth date");
form.dob.focus()
return false;
}

//coding for radio button

function radio_button_checker()
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter <form.gender.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (form.gender[counter].checked)
radio_choice = true;
}

if (!radio_choice)
{
// If there were no selections made display an alert box
alert("Please select a Gender.")
return (false);
}
return (true);
}
</script>
augustus_emperor is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old April 22nd, 2004, 09:08 AM   #2
Reputable Member
 

Join Date: Aug 2003
Location: United Kingdom
Posts: 339
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 D3mon is on a distinguished road
Its a wild guess, but try this instead:
if (form.gender[counter].<font color="red">selected</font id="red">)
D3mon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
problem , radio , button , form , validation


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] large radio button form submit chriscant JavaScript 7 October 25th, 2007 05:03 AM
redirecting form based on radio button values c_martini JavaScript 7 October 9th, 2007 06:26 AM
form validation with radio butoon yvettesio JavaScript 0 February 18th, 2007 11:31 PM
Any way to use an image for a radio button? masonbarge HTML, XHTML and CSS 23 January 6th, 2007 05:06 AM
Help needed with creating a radio button form sing2trees PHP 1 November 13th, 2006 01:52 AM


Search Engine Optimization by vBSEO 3.2.0 RC8