rowsen
asked on
Script to make sure at least one option is ticked in a submittal form
I am at an end to add a code to check my form to be sure that one of the options on my form are ticked. I have been researching EE with no success. Please forward needed code to check the option buttons. I am very new to working with submittal forms.
Thanks
Robert
Thanks
Robert
<script language="javascript" type="text/javascript">
function isValidEmail(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function IsEmpty(aTextField) {
if ((aTextField.value.length==0) ||
(aTextField.value==null)) {
return true;
}
else { return false; }
}
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
function ValidateForm(form)
{
if(IsEmpty(form.firstname))
{
alert('Please enter your First Name!')
return false;
}
if (!isValidEmail(form.email.value))
{
alert('Please enter correct email address!')
return false;
}
if(IsEmpty(form.comments))
{
alert('Please enter your comments!')
// form.account_number.focus();
return false;
}
return true;
}
</script>
</HEAD>
<BODY>
<FORM action="formmail_response.cfm" method="post" onsubmit="javascript:return ValidateForm(this)">
<P><INPUT type=hidden value=robert@rwsmin.org name=_recipients> <INPUT
type=hidden value="Rowsen IT Applications: " name=_subject>
<P>Required Information is marked ( <span class="style1">*</span> )
<P>First Name <span class="style1">*</span>:
<input name="firstname" type="text">
<P>Last Name:
<input name="lastname" type="text">
<P>Phone Number :
<input name="phonenumber" type="text" size="20" maxlength="20">
<P> Email Address <span class="style1">*</span>:
<input name="email" size="35">
<P> Comments <span class="style1">*</span>:<BR>
<TEXTAREA name="comments" cols=58 rows=9></TEXTAREA>
<P>Option Is Required ( <span class="style1">*</span> )
<P>
<input name="InfoRequested" type="radio" value="I have no request from the list below.">
I have no request from the list below.<P>
<input name="InfoRequested" type="radio" value="I would like information concerning foodservice.">
I would like information concerning foodservice. <P>
<input name="InfoRequested" type="radio" value="I would like information concerning a business application.">
I would like information concerning a business application.<P>
<input name="InfoRequested" type="radio" value="I would like information concerning Bible Information ">I would like information concerning Bible Information
<BR><br>
<INPUT type=submit value=Submit>
<INPUT type=reset value=Clear>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you guys for your help, both these answers were very helpful.
Robert
Robert
Open in new window