By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,835 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,835 IT Pros & Developers. It's quick & easy.

Code Direction for radio button error check

P: 4
Hi Guys,

I know to error check a drop down field called "Reason" i would use.

if (document.HTML_FORM.Reason.options[0].selected == 1)
errorMsg += "The field Reason is mandatory and has been left blank\n";

and I know to check a text field I would use,

if (!(document.HTML_FORM.Reason.value))
errorMsg += "The field Reason is mandatory and has been left blank\n";

Question I have what code would I use for a Group of Radio buttons? I have tried the .value option.

John
Feb 22 '07 #1
Share this Question
Share on Google+
4 Replies

10K+
P: 13,262
Hi Guys,

I know to error check a drop down field called "Reason" i would use.

if (document.HTML_FORM.Reason.options[0].selected == 1)
errorMsg += "The field Reason is mandatory and has been left blank\n";

and I know to check a text field I would use,

if (!(document.HTML_FORM.Reason.value))
errorMsg += "The field Reason is mandatory and has been left blank\n";

Question I have what code would I use for a Group of Radio buttons? I have tried the .value option.

John
Java != Javascript

Moved to Javascript forum
Feb 22 '07 #2

100+
P: 157
Hi Guys,

I know to error check a drop down field called "Reason" i would use.

if (document.HTML_FORM.Reason.options[0].selected == 1)
errorMsg += "The field Reason is mandatory and has been left blank\n";

and I know to check a text field I would use,

if (!(document.HTML_FORM.Reason.value))
errorMsg += "The field Reason is mandatory and has been left blank\n";

Question I have what code would I use for a Group of Radio buttons? I have tried the .value option.

John
this might be of help.
Feb 22 '07 #3

P: 4
Top draw I got there in the end. Thank you.

var radIndex;
var INOUTIndex = 2;

for (radIndex = 0; radIndex < document.HTML_FORM.Movement_INOUT.length; radIndex++)
{
if (document.HTML_FORM.Movement_INOUT[radIndex].checked == false)
errorMsg += "Please Select In or Out on your Movment\n";
{
INOUTIndex = radIndex;
break;
}
}
Feb 23 '07 #4

100+
P: 157
Top draw I got there in the end. Thank you.

var radIndex;
var INOUTIndex = 2;

for (radIndex = 0; radIndex < document.HTML_FORM.Movement_INOUT.length; radIndex++)
{
if (document.HTML_FORM.Movement_INOUT[radIndex].checked == false)
errorMsg += "Please Select In or Out on your Movment\n";
{
INOUTIndex = radIndex;
break;
}
}
You are welcome, glad it helped.
Feb 23 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.