Platini
asked on
Submit form through email CDOSYS and CDONTS
I want to submit this form to email (CDOSYS and CDONTS) Could someone tell me how this can be done?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style2 {
font: 12px;
font-size: small;
font-family: Verdana;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
th
{ color: #000000; font-family: Tahoma, Verdana; font-size: 11px; }
.newStyle1 {
font-family: Verdana;
font-size: 12px;
background-color: #CCE6FF;
}
.newStyle2 {
color: #D9ECFF;
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
/*********************************************************************
Original Script By
Patrick Fairfield (a.k.a fritz_the_blank)
Fairfield Consulting
========================================================
Edited by Jay Solomon
jaysolomon *AT* pclnet *DOT* net
*********************************************************************/
var strAlertMsg = ""
var focusField = ""
//============================================================
//validate Date
function isDate(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName];
strDate = objFormField.value;
if(strDate.length>0){
var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
var match=strDate.match(dateregex);
if (match){
var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10)){
return true;
}
}
strAlertMsg += "- "+ strMsg +" is Required.\nExample: 01/01/2003\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
else{
return true;
}
}
//========================================================================
//Validate Us Phone. Ex. (999) 999-9999 or (999)999-9999
function isPhone(theForm,strFieldName,strMsg) {
var objFormField = theForm.elements[strFieldName];
var strValue = objFormField.value;
var objRegExp = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
if(!objRegExp.test(strValue)){
strAlertMsg += "- "+ strMsg +" is Required.\n Example:\n(999)999-9999 or (999) 999-9999\n";
if(!focusField) focusField=""+ strFieldName +"";
return false;
}
return true;
}
//========================================================================
//Validate US zip code in 5 digit format or zip+4 format. 99999 or 99999-9999
function isZipCode(theForm,strFieldName,strMsg) {
var objFormField = theForm.elements[strFieldName];
var strValue = objFormField.value;
var objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
if(!objRegExp.test(strValue)){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//==========================================================================
//Validate the Select
function hasSelection(theForm,strFieldName,strMsg) {
var objFormField = theForm.elements[strFieldName];
if(objFormField.selectedIndex ==0) {
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//========================================================================
//Validate Check Box
function isChecked(theForm,strFieldName,strMsg) {
var objFormField= theForm.elements[strFieldName];
var strValue= objFormField.checked;
if (!strValue) {
//alert("The \""+ strMsg +"\" box is checked!")
//} else {
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================================================================
//Validate Text Box
function isEmpty(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName];
var strValue = objFormField.value;
strValue = strValue.split(" ").join("")
if(strValue.length<1){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================================================================
//Validate Email
function isEmail(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName]
var strEmail = objFormField.value;
var bolValid = true;
if(strEmail.length < 7){
bolValid = false;
}
if(strEmail.lastIndexOf(" ") >0){
bolValid = false;
}
var intLastDot = strEmail.lastIndexOf(".")
if(intLastDot == -1 || strEmail.length - intLastDot >4){
bolValid = false;
}
var intAt = strEmail.lastIndexOf("@")
if(intAt == -1 || strEmail.length - intAt < 5){
bolValid = false;
}
if(!bolValid){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
}
return bolValid;
}
//========================================================================
//Validate Radio Button
function checkRadioControl(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName]
intControlLength = objFormField.length
bolSelected = false;
for (i=0;i<intControlLength;i++){
if(objFormField[i].checked){
bolSelected = true;
break;
}
}
if(! bolSelected){
if(!focusField) focusField =""+ objFormField[0].id +"";
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//========================================================================
//Compare the Fields
function compareFields(theForm,strFieldName1,strFieldName2,strMsg){
var objFormField1= theForm.elements[strFieldName1];
var objFormField2= theForm.elements[strFieldName2];
var strValue1= objFormField1.value;
var strValue2= objFormField2.value;
if(strValue1 != strValue2){
strAlertMsg +="The "+ strMsg +" fields do not match, please try again.\n";
if(!focusField) focusField =""+ strFieldName1 +"";
return false;
}
return true;
}
//========================================================================
//Format Phone Number 9999999999 = (999)999-9999
//Call the function like so onKeyPress="javascript:formatPhone(this);
function formatPhone(objFormField){
intFieldLength = objFormField.value.length;
if(intFieldLength == 3){
objFormField.value = "(" + objFormField.value + ") ";
return false;
}
if(intFieldLength >= 9 && intFieldLength <= 10){
objFormField.value = objFormField.value + "-";
return false;
}
}
//========================================================================
//End .js File
//Begin Page Validation
function validateForm(theForm){
strAlertMsg = ""
focusField = ""
isEmpty(theForm,'Customer_Name','Name')
isEmpty(theForm,'email','Email')
isEmpty(theForm,'dDate','Date')
checkRadioControl(theForm,'radio1','Radio')
checkRadioControl(theForm,'radio2','Radio')
isEmpty(theForm,'PhoneB','textbox')
checkRadioControl(theForm,'radio3','Radio')
checkRadioControl(theForm,'radio4','Radio')
checkRadioControl(theForm,'radio5','Radio')
checkRadioControl(theForm,'radio6','Radio')
checkRadioControl(theForm,'radio7','Radio')
checkRadioControl(theForm,'radio8','Radio')
checkRadioControl(theForm,'radio9','Radio')
if(strAlertMsg !=""){
alert("Please correct the following errors:\n____________________________\n\n" + strAlertMsg);
eval("theForm." + focusField + ".focus()");
//alert(focusField);
theForm[focusField].focus();
return false;
}
return true;
}
//-->
</script>
</head>
<body class="sub">
<form id="form1" action="" method="post" onsubmit="return validateForm(this);">
<table width="90%" border="0" cellspacing="2" cellpadding="4">
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px; height: 31px;">
<table cellSpacing="0" cellPadding="0" align="left" border="0" style="width: 713px">
<tr>
<th style="FONT-SIZE: 12px; COLOR: white" noWrap bgColor="#4682b4">
Visual Impairment Form<img height="1" src="pixel.gif" width="10" border="0" /></th>
<td>
<img height="21" src="formtab_r.gif" width="10" border="0" /></td>
<td width="100%" background="line_t.gif"> </td>
</tr>
</table>
</td>
</tr>
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px">
<p class="style2">
<label id="lblCustome_Name" for="Customer_Name" class="style2">Name</label>
<input type="text" id="Customer_Name" name="Customer_Name" class="newStyle1" tabindex="0" />
<br />
<label id="lblemail" for="email" class="style2">Please enter your email address</label>
<input type="text" name="email" id="email" class="newStyle1" tabindex="0" />
<br />
<label id="lbldDate" for="dDate" class="style2">Please enter today's date</label>
<input type="text" name="dDate" id="dDate" class="newStyle1" tabindex="0" />
<FIELDSET>
<LEGEND> Do you need a screen reader to
access your computer?</LEGEND>
<input type="radio" name="radio1" value="Yes" id="radio1y" class="style2" tabindex="0" />
Yes
<label><input type="radio" name="radio1" value="No" id="radio1n" class="style2" />
No</label>
</FIELDSET>
<p class="style2">
<label id="lblradio2" for="radio2">Do you need to hear your screen reader
while on the phone?</label>
<input type="radio" name="radio2" value="Yes" id="radio2y" class="style2" tabindex="0" />
Yes
<input type="radio" name="radio2" value="No" id="radio2n" class="style2" />
No
<p class="style2">
<label id="lblFname" for="PhoneB">What brand and model of phone do you
use?
</label>
<textarea name="PhoneB" id="PhoneB" rows="5" class="newStyle1" style="width: 373px" tabindex="0"></textarea>
<p class="style2">
<span class="style3">
<label>Do you need a braille display for reading information on your
computer?</label>
<label id="lblFname" for="radio3">
<input type="radio" name="radio3" value="Yes" id="radio3y" class="style2" tabindex="0" />
Yes</label>
<label>
<input type="radio" name="radio3" value="No" id="radio3n" class="style2" tabindex="0" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you prefer a 40 or 80 cell braille display?</label>
<label id="lblFname" for="radio4">
<input type="radio" name="radio4" value="40 cell" id="radio4y" class="style2" tabindex="0" />
40 cell</label>
<label>
<input type="radio" name="radio4" value="80 cell" id="radio4n" class="style2" tabindex="0" />
80 cell</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to access printed materials to complete your daily
assignments?</label>
<label id="lblFname" for="radio5"><input type="radio" name="radio5" value="Yes" id="radio5y" />
Yes</label>
<label>
<input name="radio5" type="radio" id="radio5n" value="No" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to produce hardcopy braille materials in your daily
work activities?</label>
<label id="lblFname" for="radio6"><input type="radio" name="radio6" value="Yes" id="radio6y" />
Yes</label>
<label>
<input type="radio" name="radio6" value="No" id="radio6n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have access to a shared braille embosser (printer)?</label>
<label id="lblFname" for="radio7"><input type="radio" name="radio7" value="Yes" id="radio7y" />
Yes</label>
<label>
<input type="radio" name="radio7" value="No" id="radio7n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have issues locating keys on your keyboard?</label>
<label id="lblFname" for="radio8"><input type="radio" name="radio8" value="Yes" id="radio8y" />
Yes</label>
<label>
<input type="radio" name="radio8" value="No" id="radio8n" />
No</label>
</span></p>
<p class="StoryContentColor style2 style3"><span class="style2">
<label>Do you need to take notes during meetings away from your desk
and/or in training sessions?</label>
<label id="lblFname" for="radio9"><input type="radio" name="radio9" value="Yes" id="radio9y" />
Yes</label>
<label>
<input type="radio" name="radio9" value="No" id="radio9n" />
No</label>
</span></p></td>
</tr>
<tr style="vertical-align: top">
<td style="width: 722px">
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
<input type="reset" id="btnReset" name="btnReset" value="Reset" />
</td>
</tr>
</table>
</form>
</body>
</html>
NOTE: Make sure you update the action attribute of your form as shown on my post
ASKER
I will verify this next morining. Thanks Hielo!
I just noticed a mistake. This:
var myMail=CreateObject("CDO.M essage");
should be:
var myMail=Server.CreateObject ("CDO.Mess age");
var myMail=CreateObject("CDO.M
should be:
var myMail=Server.CreateObject
ASKER
I get page not found error, any ideas?
Set the action attribute of your <form> tag so that it points to the ASP page that will be sending the email. Page not found is a clear indication that you are not sending/submitting the form to the right place.
For the purposes of testing, save my first post as hieloEmail.asp, apply the update I mentioned on my previous post, provide your email info, then load it from your browser. Fill the form and submit.
For the purposes of testing, save my first post as hieloEmail.asp, apply the update I mentioned on my previous post, provide your email info, then load it from your browser. Fill the form and submit.
ASKER
This is what I have in wizard_email.asp that gets called from form action in wizard.asp. I get "HTTP 500 internal server error now. Am I doing this incorrectly?
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="wizard_proc.asp. vb" Inherits="_508_wizard_proc " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<%@LANGAUGE="JAVASCRIPT"%>
<%
if("undefined" != String(Request("btnSubmit" )) )
{
var data = "";
data += "\nCustomer Name: " + Request("Customer_Name");
data += "\nEmail: " + Request("email");
data += "\nDate: " + Request("dDate");
data += "\nRadio 1: " + Request("radio1");
data += "\nRadio 2: " + Request("radio2");
data += "\nRadio 3: " + Request("radio3");
data += "\nRadio 4: " + Request("radio4");
data += "\nRadio 5: " + Request("radio5");
data += "\nRadio 6: " + Request("radio6");
data += "\nRadio 7: " + Request("radio7");
data += "\nRadio 8: " + Request("radio8");
data += "\nRadio 9: " + Request("radio9");
var myMail=Server.CreateObject ("CDO.Mess age");
myMail.Subject="Sending email with CDO";
myMail.From="dar@ssi.com";
myMail.To="dar.z@ssi.com";
myMail.TextBody=data;
myMail.Send();
myMail=null;
Response.Write("Thank You!")
Response.End
}
%>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="wizard_proc.asp.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<%@LANGAUGE="JAVASCRIPT"%>
<%
if("undefined" != String(Request("btnSubmit"
{
var data = "";
data += "\nCustomer Name: " + Request("Customer_Name");
data += "\nEmail: " + Request("email");
data += "\nDate: " + Request("dDate");
data += "\nRadio 1: " + Request("radio1");
data += "\nRadio 2: " + Request("radio2");
data += "\nRadio 3: " + Request("radio3");
data += "\nRadio 4: " + Request("radio4");
data += "\nRadio 5: " + Request("radio5");
data += "\nRadio 6: " + Request("radio6");
data += "\nRadio 7: " + Request("radio7");
data += "\nRadio 8: " + Request("radio8");
data += "\nRadio 9: " + Request("radio9");
var myMail=Server.CreateObject
myMail.Subject="Sending email with CDO";
myMail.From="dar@ssi.com";
myMail.To="dar.z@ssi.com";
myMail.TextBody=data;
myMail.Send();
myMail=null;
Response.Write("Thank You!")
Response.End
}
%>
</body>
</html>
What I gave you is an ASP page. What you posted is as ASPX page. Open Notepad, paste the code I gave you. Supply the email info. Save it to whereever you want it on you web server. Load it through browser. Done.
ASKER
Do you want me to paste the entire code above into the notepad or just the top JavaScript?
The entire code is a complete file. When the user gets to the page for the first time, it will not detect any submitted info so it will display the form. Once the user submits the info, it will email the data to you.
ASKER
action="<%=Request.ServerV ariables(' SCRIPT_NAM E')%>"
Is this action executing at all? is the "script_name" correct?
Is this action executing at all? is the "script_name" correct?
>>action="<%=Request.Serve rVariables ('SCRIPT_N AME')%>"
This part:
Request.ServerVariables('S CRIPT_NAME ')
is supposed to give you the name of the executing script. So if you save you file as:
http://www.yourdomain.com/myscripts/test.asp
then it should evaluate to:
/myscripts/test.asp
The <%=%> is an ASP shorthand for Response.Write. So esssentially that line says:
action="Response.Write('/m yscripts/t est.asp')"
If it is giving you problems, then change manually to the name of your script:
action="/myscripts/test.as p"
This part:
Request.ServerVariables('S
is supposed to give you the name of the executing script. So if you save you file as:
http://www.yourdomain.com/myscripts/test.asp
then it should evaluate to:
/myscripts/test.asp
The <%=%> is an ASP shorthand for Response.Write. So esssentially that line says:
action="Response.Write('/m
If it is giving you problems, then change manually to the name of your script:
action="/myscripts/test.as
ASKER
Ok, so I did copy and pasted all code into notepad and saved it as wizard.asp. I modified the action and upladed to the server for testing and got "the page cannot be displayed" error. code is below:
<%@LANGAUGE="JAVASCRIPT"%>
<%
if("undefined" != String(Request("btnSubmit" )) )
{
var data = "";
data += "\nCustomer Name: " + Request("Customer_Name");
data += "\nEmail: " + Request("email");
data += "\nDate: " + Request("dDate");
data += "\nRadio 1: " + Request("radio1");
data += "\nRadio 2: " + Request("radio2");
data += "\nPhoneB: " + Request("PhoneB");
data += "\nRadio 3: " + Request("radio3");
data += "\nRadio 4: " + Request("radio4");
data += "\nRadio 5: " + Request("radio5");
data += "\nRadio 6: " + Request("radio6");
data += "\nRadio 7: " + Request("radio7");
data += "\nRadio 8: " + Request("radio8");
data += "\nRadio 9: " + Request("radio9");
var myMail=Server.CreateObject ("CDO.Mess age");
myMail.Subject="Sending email with CDO";
myMail.From="test@ssi.com" ;
myMail.To="test1@ssi.com";
myMail.Bcc="someoneelse@so medomain.c om";
myMail.Cc="someoneelse2@so medomain.c om";
myMail.TextBody=data;
myMail.Send();
myMail=null;
Response.Write("Thank You!")
Response.End
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-micro soft-com:v ml" xmlns:o="urn:schemas-micro soft-com:o ffice:offi ce">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style2 {
font: 12px;
font-size: small;
font-family: Verdana;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
th
{ color: #000000; font-family: Tahoma, Verdana; font-size: 11px; }
.newStyle1 {
font-family: Verdana;
font-size: 12px;
background-color: #CCE6FF;
}
.newStyle2 {
color: #D9ECFF;
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
/************************* ********** ********** ********** ********** ****
Original Script By
Patrick Fairfield (a.k.a fritz_the_blank)
Fairfield Consulting
========================== ========== ========== ==========
Edited by Jay Solomon
jaysolomon *AT* pclnet *DOT* net
************************** ********** ********** ********** ********** ***/
var strAlertMsg = ""
var focusField = ""
//======================== ========== ========== ========== ======
//validate Date
function isDate(theForm,strFieldNam e,strMsg){
var objFormField = theForm.elements[strFieldN ame];
strDate = objFormField.value;
if(strDate.length>0){
var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2}) \/(\d{4,}) [ ]*$/;
var match=strDate.match(datere gex);
if (match){
var tmpdate=new Date(match[3],parseInt(mat ch[1],10)- 1,match[2] );
if (tmpdate.getDate()==parseI nt(match[2 ],10) && tmpdate.getFullYear()==par seInt(matc h[3],10) && (tmpdate.getMonth()+1)==pa rseInt(mat ch[1],10)) {
return true;
}
}
strAlertMsg += "- "+ strMsg +" is Required.\nExample: 01/01/2003\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
else{
return true;
}
}
//======================== ========== ========== ========== ========== ========
//Validate Us Phone. Ex. (999) 999-9999 or (999)999-9999
function isPhone(theForm,strFieldNa me,strMsg) {
var objFormField = theForm.elements[strFieldN ame];
var strValue = objFormField.value;
var objRegExp = /^\([1-9]\d{2}\)\s?\d{3}\- \d{4}$/;
if(!objRegExp.test(strValu e)){
strAlertMsg += "- "+ strMsg +" is Required.\n Example:\n(999)999-9999 or (999) 999-9999\n";
if(!focusField) focusField=""+ strFieldName +"";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ========
//Validate US zip code in 5 digit format or zip+4 format. 99999 or 99999-9999
function isZipCode(theForm,strField Name,strMs g) {
var objFormField = theForm.elements[strFieldN ame];
var strValue = objFormField.value;
var objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$) /;
if(!objRegExp.test(strValu e)){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ==========
//Validate the Select
function hasSelection(theForm,strFi eldName,st rMsg) {
var objFormField = theForm.elements[strFieldN ame];
if(objFormField.selectedIn dex ==0) {
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ========
//Validate Check Box
function isChecked(theForm,strField Name,strMs g) {
var objFormField= theForm.elements[strFieldN ame];
var strValue= objFormField.checked;
if (!strValue) {
//alert("The \""+ strMsg +"\" box is checked!")
//} else {
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ========
//Validate Text Box
function isEmpty(theForm,strFieldNa me,strMsg) {
var objFormField = theForm.elements[strFieldN ame];
var strValue = objFormField.value;
strValue = strValue.split(" ").join("")
if(strValue.length<1){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ========
//Validate Email
function isEmail(theForm,strFieldNa me,strMsg) {
var objFormField = theForm.elements[strFieldN ame]
var strEmail = objFormField.value;
var bolValid = true;
if(strEmail.length < 7){
bolValid = false;
}
if(strEmail.lastIndexOf(" ") >0){
bolValid = false;
}
var intLastDot = strEmail.lastIndexOf(".")
if(intLastDot == -1 || strEmail.length - intLastDot >4){
bolValid = false;
}
var intAt = strEmail.lastIndexOf("@")
if(intAt == -1 || strEmail.length - intAt < 5){
bolValid = false;
}
if(!bolValid){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
}
return bolValid;
}
//======================== ========== ========== ========== ========== ========
//Validate Radio Button
function checkRadioControl(theForm, strFieldNa me,strMsg) {
var objFormField = theForm.elements[strFieldN ame]
intControlLength = objFormField.length
bolSelected = false;
for (i=0;i<intControlLength;i+ +){
if(objFormField[i].checked ){
bolSelected = true;
break;
}
}
if(! bolSelected){
if(!focusField) focusField =""+ objFormField[0].id +"";
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ========
//Compare the Fields
function compareFields(theForm,strF ieldName1, strFieldNa me2,strMsg ){
var objFormField1= theForm.elements[strFieldN ame1];
var objFormField2= theForm.elements[strFieldN ame2];
var strValue1= objFormField1.value;
var strValue2= objFormField2.value;
if(strValue1 != strValue2){
strAlertMsg +="The "+ strMsg +" fields do not match, please try again.\n";
if(!focusField) focusField =""+ strFieldName1 +"";
return false;
}
return true;
}
//======================== ========== ========== ========== ========== ========
//Format Phone Number 9999999999 = (999)999-9999
//Call the function like so onKeyPress="javascript:for matPhone(t his);
function formatPhone(objFormField){
intFieldLength = objFormField.value.length;
if(intFieldLength == 3){
objFormField.value = "(" + objFormField.value + ") ";
return false;
}
if(intFieldLength >= 9 && intFieldLength <= 10){
objFormField.value = objFormField.value + "-";
return false;
}
}
//======================== ========== ========== ========== ========== ========
//End .js File
//Begin Page Validation
function validateForm(theForm){
strAlertMsg = ""
focusField = ""
isEmpty(theForm,'Customer_ Name','Nam e')
isEmpty(theForm,'email','E mail')
isEmpty(theForm,'dDate','D ate')
checkRadioControl(theForm, 'radio1',' Radio')
checkRadioControl(theForm, 'radio2',' Radio')
isEmpty(theForm,'PhoneB',' textbox')
checkRadioControl(theForm, 'radio3',' Radio')
checkRadioControl(theForm, 'radio4',' Radio')
checkRadioControl(theForm, 'radio5',' Radio')
checkRadioControl(theForm, 'radio6',' Radio')
checkRadioControl(theForm, 'radio7',' Radio')
checkRadioControl(theForm, 'radio8',' Radio')
checkRadioControl(theForm, 'radio9',' Radio')
if(strAlertMsg !=""){
alert("Please correct the following errors:\n_________________ __________ _\n\n" + strAlertMsg);
eval("theForm." + focusField + ".focus()");
//alert(focusField);
theForm[focusField].focus( );
return false;
}
return true;
}
//-->
</script>
</head>
<body class="sub">
<form id="form1" action="/508/wizard.asp" method="post" onsubmit="return validateForm(this);">
<table width="90%" border="0" cellspacing="2" cellpadding="4">
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px; height: 31px;">
<table cellSpacing="0" cellPadding="0" align="left" border="0" style="width: 713px">
<tr>
<th style="FONT-SIZE: 12px; COLOR: white" noWrap bgColor="#4682b4">
Visual Impairment Form<img height="1" src="pixel.gif" width="10" border="0" /></th>
<td>
<img height="21" src="formtab_r.gif" width="10" border="0" /></td>
<td width="100%" background="line_t.gif"> </td>
</tr>
</table>
</td>
</tr>
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px">
<p class="style2">
<label id="lblCustome_Name" for="Customer_Name" class="style2">Name</label >
<input type="text" id="Customer_Name" name="Customer_Name" class="newStyle1" tabindex="0" />
<label id="lblemail" for="email" class="style2">Please enter your email address</label>
<input type="text" name="email" id="email" class="newStyle1" tabindex="0" />
<label id="lbldDate" for="dDate" class="style2">Please enter today's date</label>
<input type="text" name="dDate" id="dDate" class="newStyle1" tabindex="0" />
<FIELDSET>
<LEGEND> Do you need a screen reader to
access your computer?</LEGEND>
<input type="radio" name="radio1" value="Yes" id="radio1y" class="style2" tabindex="0" />
Yes
<label><input type="radio" name="radio1" value="No" id="radio1n" class="style2" />
No</label>
</FIELDSET>
<p class="style2">
<label id="lblradio2" for="radio2">Do you need to hear your screen reader
while on the phone?</label>
<input type="radio" name="radio2" value="Yes" id="radio2y" class="style2" tabindex="0" />
Yes
<input type="radio" name="radio2" value="No" id="radio2n" class="style2" />
No
<p class="style2">
<label id="lblFname" for="PhoneB">What brand and model of phone do you
use?
</label>
<textarea name="PhoneB" id="PhoneB" rows="5" class="newStyle1" style="width: 373px" tabindex="0"></textarea>
<p class="style2">
<span class="style3">
<label>Do you need a braille display for reading information on your
computer?</label>
<label id="lblFname" for="radio3">
<input type="radio" name="radio3" value="Yes" id="radio3y" class="style2" tabindex="0" />
Yes</label>
<label>
<input type="radio" name="radio3" value="No" id="radio3n" class="style2" tabindex="0" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you prefer a 40 or 80 cell braille display?</label>
<label id="lblFname" for="radio4">
<input type="radio" name="radio4" value="40 cell" id="radio4y" class="style2" tabindex="0" />
40 cell</label>
<label>
<input type="radio" name="radio4" value="80 cell" id="radio4n" class="style2" tabindex="0" />
80 cell</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to access printed materials to complete your daily
assignments?</label>
<label id="lblFname" for="radio5"><input type="radio" name="radio5" value="Yes" id="radio5y" />
Yes</label>
<label>
<input name="radio5" type="radio" id="radio5n" value="No" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to produce hardcopy braille materials in your daily
work activities?</label>
<label id="lblFname" for="radio6"><input type="radio" name="radio6" value="Yes" id="radio6y" />
Yes</label>
<label>
<input type="radio" name="radio6" value="No" id="radio6n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have access to a shared braille embosser (printer)?</label>
<label id="lblFname" for="radio7"><input type="radio" name="radio7" value="Yes" id="radio7y" />
Yes</label>
<label>
<input type="radio" name="radio7" value="No" id="radio7n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have issues locating keys on your keyboard?</label>
<label id="lblFname" for="radio8"><input type="radio" name="radio8" value="Yes" id="radio8y" />
Yes</label>
<label>
<input type="radio" name="radio8" value="No" id="radio8n" />
No</label>
</span></p>
<p class="StoryContentColor style2 style3"><span class="style2">
<label>Do you need to take notes during meetings away from your desk
and/or in training sessions?</label>
<label id="lblFname" for="radio9"><input type="radio" name="radio9" value="Yes" id="radio9y" />
Yes</label>
<label>
<input type="radio" name="radio9" value="No" id="radio9n" />
No</label>
</span></p></td>
</tr>
<tr style="vertical-align: top">
<td style="width: 722px">
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
<input type="reset" id="btnReset" name="btnReset" value="Reset" />
</td>
</tr>
</table>
</form>
</body>
</html>
<%@LANGAUGE="JAVASCRIPT"%>
<%
if("undefined" != String(Request("btnSubmit"
{
var data = "";
data += "\nCustomer Name: " + Request("Customer_Name");
data += "\nEmail: " + Request("email");
data += "\nDate: " + Request("dDate");
data += "\nRadio 1: " + Request("radio1");
data += "\nRadio 2: " + Request("radio2");
data += "\nPhoneB: " + Request("PhoneB");
data += "\nRadio 3: " + Request("radio3");
data += "\nRadio 4: " + Request("radio4");
data += "\nRadio 5: " + Request("radio5");
data += "\nRadio 6: " + Request("radio6");
data += "\nRadio 7: " + Request("radio7");
data += "\nRadio 8: " + Request("radio8");
data += "\nRadio 9: " + Request("radio9");
var myMail=Server.CreateObject
myMail.Subject="Sending email with CDO";
myMail.From="test@ssi.com"
myMail.To="test1@ssi.com";
myMail.Bcc="someoneelse@so
myMail.Cc="someoneelse2@so
myMail.TextBody=data;
myMail.Send();
myMail=null;
Response.Write("Thank You!")
Response.End
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-micro
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style2 {
font: 12px;
font-size: small;
font-family: Verdana;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
th
{ color: #000000; font-family: Tahoma, Verdana; font-size: 11px; }
.newStyle1 {
font-family: Verdana;
font-size: 12px;
background-color: #CCE6FF;
}
.newStyle2 {
color: #D9ECFF;
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
/*************************
Original Script By
Patrick Fairfield (a.k.a fritz_the_blank)
Fairfield Consulting
==========================
Edited by Jay Solomon
jaysolomon *AT* pclnet *DOT* net
**************************
var strAlertMsg = ""
var focusField = ""
//========================
//validate Date
function isDate(theForm,strFieldNam
var objFormField = theForm.elements[strFieldN
strDate = objFormField.value;
if(strDate.length>0){
var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})
var match=strDate.match(datere
if (match){
var tmpdate=new Date(match[3],parseInt(mat
if (tmpdate.getDate()==parseI
return true;
}
}
strAlertMsg += "- "+ strMsg +" is Required.\nExample: 01/01/2003\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
else{
return true;
}
}
//========================
//Validate Us Phone. Ex. (999) 999-9999 or (999)999-9999
function isPhone(theForm,strFieldNa
var objFormField = theForm.elements[strFieldN
var strValue = objFormField.value;
var objRegExp = /^\([1-9]\d{2}\)\s?\d{3}\-
if(!objRegExp.test(strValu
strAlertMsg += "- "+ strMsg +" is Required.\n Example:\n(999)999-9999 or (999) 999-9999\n";
if(!focusField) focusField=""+ strFieldName +"";
return false;
}
return true;
}
//========================
//Validate US zip code in 5 digit format or zip+4 format. 99999 or 99999-9999
function isZipCode(theForm,strField
var objFormField = theForm.elements[strFieldN
var strValue = objFormField.value;
var objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)
if(!objRegExp.test(strValu
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================
//Validate the Select
function hasSelection(theForm,strFi
var objFormField = theForm.elements[strFieldN
if(objFormField.selectedIn
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//========================
//Validate Check Box
function isChecked(theForm,strField
var objFormField= theForm.elements[strFieldN
var strValue= objFormField.checked;
if (!strValue) {
//alert("The \""+ strMsg +"\" box is checked!")
//} else {
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================
//Validate Text Box
function isEmpty(theForm,strFieldNa
var objFormField = theForm.elements[strFieldN
var strValue = objFormField.value;
strValue = strValue.split(" ").join("")
if(strValue.length<1){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================
//Validate Email
function isEmail(theForm,strFieldNa
var objFormField = theForm.elements[strFieldN
var strEmail = objFormField.value;
var bolValid = true;
if(strEmail.length < 7){
bolValid = false;
}
if(strEmail.lastIndexOf(" ") >0){
bolValid = false;
}
var intLastDot = strEmail.lastIndexOf(".")
if(intLastDot == -1 || strEmail.length - intLastDot >4){
bolValid = false;
}
var intAt = strEmail.lastIndexOf("@")
if(intAt == -1 || strEmail.length - intAt < 5){
bolValid = false;
}
if(!bolValid){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
}
return bolValid;
}
//========================
//Validate Radio Button
function checkRadioControl(theForm,
var objFormField = theForm.elements[strFieldN
intControlLength = objFormField.length
bolSelected = false;
for (i=0;i<intControlLength;i+
if(objFormField[i].checked
bolSelected = true;
break;
}
}
if(! bolSelected){
if(!focusField) focusField =""+ objFormField[0].id +"";
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//========================
//Compare the Fields
function compareFields(theForm,strF
var objFormField1= theForm.elements[strFieldN
var objFormField2= theForm.elements[strFieldN
var strValue1= objFormField1.value;
var strValue2= objFormField2.value;
if(strValue1 != strValue2){
strAlertMsg +="The "+ strMsg +" fields do not match, please try again.\n";
if(!focusField) focusField =""+ strFieldName1 +"";
return false;
}
return true;
}
//========================
//Format Phone Number 9999999999 = (999)999-9999
//Call the function like so onKeyPress="javascript:for
function formatPhone(objFormField){
intFieldLength = objFormField.value.length;
if(intFieldLength == 3){
objFormField.value = "(" + objFormField.value + ") ";
return false;
}
if(intFieldLength >= 9 && intFieldLength <= 10){
objFormField.value = objFormField.value + "-";
return false;
}
}
//========================
//End .js File
//Begin Page Validation
function validateForm(theForm){
strAlertMsg = ""
focusField = ""
isEmpty(theForm,'Customer_
isEmpty(theForm,'email','E
isEmpty(theForm,'dDate','D
checkRadioControl(theForm,
checkRadioControl(theForm,
isEmpty(theForm,'PhoneB','
checkRadioControl(theForm,
checkRadioControl(theForm,
checkRadioControl(theForm,
checkRadioControl(theForm,
checkRadioControl(theForm,
checkRadioControl(theForm,
checkRadioControl(theForm,
if(strAlertMsg !=""){
alert("Please correct the following errors:\n_________________
eval("theForm." + focusField + ".focus()");
//alert(focusField);
theForm[focusField].focus(
return false;
}
return true;
}
//-->
</script>
</head>
<body class="sub">
<form id="form1" action="/508/wizard.asp" method="post" onsubmit="return validateForm(this);">
<table width="90%" border="0" cellspacing="2" cellpadding="4">
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px; height: 31px;">
<table cellSpacing="0" cellPadding="0" align="left" border="0" style="width: 713px">
<tr>
<th style="FONT-SIZE: 12px; COLOR: white" noWrap bgColor="#4682b4">
Visual Impairment Form<img height="1" src="pixel.gif" width="10" border="0" /></th>
<td>
<img height="21" src="formtab_r.gif" width="10" border="0" /></td>
<td width="100%" background="line_t.gif"> </td>
</tr>
</table>
</td>
</tr>
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px">
<p class="style2">
<label id="lblCustome_Name" for="Customer_Name" class="style2">Name</label
<input type="text" id="Customer_Name" name="Customer_Name" class="newStyle1" tabindex="0" />
<label id="lblemail" for="email" class="style2">Please enter your email address</label>
<input type="text" name="email" id="email" class="newStyle1" tabindex="0" />
<label id="lbldDate" for="dDate" class="style2">Please enter today's date</label>
<input type="text" name="dDate" id="dDate" class="newStyle1" tabindex="0" />
<FIELDSET>
<LEGEND> Do you need a screen reader to
access your computer?</LEGEND>
<input type="radio" name="radio1" value="Yes" id="radio1y" class="style2" tabindex="0" />
Yes
<label><input type="radio" name="radio1" value="No" id="radio1n" class="style2" />
No</label>
</FIELDSET>
<p class="style2">
<label id="lblradio2" for="radio2">Do you need to hear your screen reader
while on the phone?</label>
<input type="radio" name="radio2" value="Yes" id="radio2y" class="style2" tabindex="0" />
Yes
<input type="radio" name="radio2" value="No" id="radio2n" class="style2" />
No
<p class="style2">
<label id="lblFname" for="PhoneB">What brand and model of phone do you
use?
</label>
<textarea name="PhoneB" id="PhoneB" rows="5" class="newStyle1" style="width: 373px" tabindex="0"></textarea>
<p class="style2">
<span class="style3">
<label>Do you need a braille display for reading information on your
computer?</label>
<label id="lblFname" for="radio3">
<input type="radio" name="radio3" value="Yes" id="radio3y" class="style2" tabindex="0" />
Yes</label>
<label>
<input type="radio" name="radio3" value="No" id="radio3n" class="style2" tabindex="0" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you prefer a 40 or 80 cell braille display?</label>
<label id="lblFname" for="radio4">
<input type="radio" name="radio4" value="40 cell" id="radio4y" class="style2" tabindex="0" />
40 cell</label>
<label>
<input type="radio" name="radio4" value="80 cell" id="radio4n" class="style2" tabindex="0" />
80 cell</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to access printed materials to complete your daily
assignments?</label>
<label id="lblFname" for="radio5"><input type="radio" name="radio5" value="Yes" id="radio5y" />
Yes</label>
<label>
<input name="radio5" type="radio" id="radio5n" value="No" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to produce hardcopy braille materials in your daily
work activities?</label>
<label id="lblFname" for="radio6"><input type="radio" name="radio6" value="Yes" id="radio6y" />
Yes</label>
<label>
<input type="radio" name="radio6" value="No" id="radio6n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have access to a shared braille embosser (printer)?</label>
<label id="lblFname" for="radio7"><input type="radio" name="radio7" value="Yes" id="radio7y" />
Yes</label>
<label>
<input type="radio" name="radio7" value="No" id="radio7n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have issues locating keys on your keyboard?</label>
<label id="lblFname" for="radio8"><input type="radio" name="radio8" value="Yes" id="radio8y" />
Yes</label>
<label>
<input type="radio" name="radio8" value="No" id="radio8n" />
No</label>
</span></p>
<p class="StoryContentColor style2 style3"><span class="style2">
<label>Do you need to take notes during meetings away from your desk
and/or in training sessions?</label>
<label id="lblFname" for="radio9"><input type="radio" name="radio9" value="Yes" id="radio9y" />
Yes</label>
<label>
<input type="radio" name="radio9" value="No" id="radio9n" />
No</label>
</span></p></td>
</tr>
<tr style="vertical-align: top">
<td style="width: 722px">
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
<input type="reset" id="btnReset" name="btnReset" value="Reset" />
</td>
</tr>
</table>
</form>
</body>
</html>
ASKER
sorry the post above is incorrect. Below is the correct code
<%@LANGAUGE="JAVASCRIPT"%>
<%
if("undefined" != String(Request("btnSubmit")) )
{
var data = "";
data += "\nCustomer Name: " + Request("Customer_Name");
data += "\nEmail: " + Request("email");
data += "\nDate: " + Request("dDate");
data += "\nRadio 1: " + Request("radio1");
data += "\nRadio 2: " + Request("radio2");
data += "\nPhoneB: " + Request("PhoneB");
data += "\nRadio 3: " + Request("radio3");
data += "\nRadio 4: " + Request("radio4");
data += "\nRadio 5: " + Request("radio5");
data += "\nRadio 6: " + Request("radio6");
data += "\nRadio 7: " + Request("radio7");
data += "\nRadio 8: " + Request("radio8");
data += "\nRadio 9: " + Request("radio9");
var myMail=Server.CreateObject("CDO.Message");
myMail.Subject="Sending email with CDO";
myMail.From="test@ssi.com";
myMail.To="test1@ssi.com";
myMail.Bcc="someoneelse@somedomain.com";
myMail.Cc="someoneelse2@somedomain.com";
myMail.TextBody=data;
myMail.Send();
myMail=null;
Response.Write("Thank You!")
Response.End
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style2 {
font: 12px;
font-size: small;
font-family: Verdana;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
th
{ color: #000000; font-family: Tahoma, Verdana; font-size: 11px; }
.newStyle1 {
font-family: Verdana;
font-size: 12px;
background-color: #CCE6FF;
}
.newStyle2 {
color: #D9ECFF;
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
/*********************************************************************
Original Script By
Patrick Fairfield (a.k.a fritz_the_blank)
Fairfield Consulting
========================================================
Edited by Jay Solomon
jaysolomon *AT* pclnet *DOT* net
*********************************************************************/
var strAlertMsg = ""
var focusField = ""
//============================================================
//validate Date
function isDate(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName];
strDate = objFormField.value;
if(strDate.length>0){
var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
var match=strDate.match(dateregex);
if (match){
var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10)){
return true;
}
}
strAlertMsg += "- "+ strMsg +" is Required.\nExample: 01/01/2003\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
else{
return true;
}
}
//========================================================================
//Validate Us Phone. Ex. (999) 999-9999 or (999)999-9999
function isPhone(theForm,strFieldName,strMsg) {
var objFormField = theForm.elements[strFieldName];
var strValue = objFormField.value;
var objRegExp = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
if(!objRegExp.test(strValue)){
strAlertMsg += "- "+ strMsg +" is Required.\n Example:\n(999)999-9999 or (999) 999-9999\n";
if(!focusField) focusField=""+ strFieldName +"";
return false;
}
return true;
}
//========================================================================
//Validate US zip code in 5 digit format or zip+4 format. 99999 or 99999-9999
function isZipCode(theForm,strFieldName,strMsg) {
var objFormField = theForm.elements[strFieldName];
var strValue = objFormField.value;
var objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
if(!objRegExp.test(strValue)){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//==========================================================================
//Validate the Select
function hasSelection(theForm,strFieldName,strMsg) {
var objFormField = theForm.elements[strFieldName];
if(objFormField.selectedIndex ==0) {
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//========================================================================
//Validate Check Box
function isChecked(theForm,strFieldName,strMsg) {
var objFormField= theForm.elements[strFieldName];
var strValue= objFormField.checked;
if (!strValue) {
//alert("The \""+ strMsg +"\" box is checked!")
//} else {
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================================================================
//Validate Text Box
function isEmpty(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName];
var strValue = objFormField.value;
strValue = strValue.split(" ").join("")
if(strValue.length<1){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
return false;
}
return true;
}
//========================================================================
//Validate Email
function isEmail(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName]
var strEmail = objFormField.value;
var bolValid = true;
if(strEmail.length < 7){
bolValid = false;
}
if(strEmail.lastIndexOf(" ") >0){
bolValid = false;
}
var intLastDot = strEmail.lastIndexOf(".")
if(intLastDot == -1 || strEmail.length - intLastDot >4){
bolValid = false;
}
var intAt = strEmail.lastIndexOf("@")
if(intAt == -1 || strEmail.length - intAt < 5){
bolValid = false;
}
if(!bolValid){
strAlertMsg += "- "+ strMsg +" is Required.\n";
if(!focusField) focusField =""+ strFieldName +"";
}
return bolValid;
}
//========================================================================
//Validate Radio Button
function checkRadioControl(theForm,strFieldName,strMsg){
var objFormField = theForm.elements[strFieldName]
intControlLength = objFormField.length
bolSelected = false;
for (i=0;i<intControlLength;i++){
if(objFormField[i].checked){
bolSelected = true;
break;
}
}
if(! bolSelected){
if(!focusField) focusField =""+ objFormField[0].id +"";
strAlertMsg += "- "+ strMsg +" is Required.\n";
return false;
}
return true;
}
//========================================================================
//Compare the Fields
function compareFields(theForm,strFieldName1,strFieldName2,strMsg){
var objFormField1= theForm.elements[strFieldName1];
var objFormField2= theForm.elements[strFieldName2];
var strValue1= objFormField1.value;
var strValue2= objFormField2.value;
if(strValue1 != strValue2){
strAlertMsg +="The "+ strMsg +" fields do not match, please try again.\n";
if(!focusField) focusField =""+ strFieldName1 +"";
return false;
}
return true;
}
//========================================================================
//Format Phone Number 9999999999 = (999)999-9999
//Call the function like so onKeyPress="javascript:formatPhone(this);
function formatPhone(objFormField){
intFieldLength = objFormField.value.length;
if(intFieldLength == 3){
objFormField.value = "(" + objFormField.value + ") ";
return false;
}
if(intFieldLength >= 9 && intFieldLength <= 10){
objFormField.value = objFormField.value + "-";
return false;
}
}
//========================================================================
//End .js File
//Begin Page Validation
function validateForm(theForm){
strAlertMsg = ""
focusField = ""
isEmpty(theForm,'Customer_Name','Name')
isEmpty(theForm,'email','Email')
isEmpty(theForm,'dDate','Date')
checkRadioControl(theForm,'radio1','Radio')
checkRadioControl(theForm,'radio2','Radio')
isEmpty(theForm,'PhoneB','textbox')
checkRadioControl(theForm,'radio3','Radio')
checkRadioControl(theForm,'radio4','Radio')
checkRadioControl(theForm,'radio5','Radio')
checkRadioControl(theForm,'radio6','Radio')
checkRadioControl(theForm,'radio7','Radio')
checkRadioControl(theForm,'radio8','Radio')
checkRadioControl(theForm,'radio9','Radio')
if(strAlertMsg !=""){
alert("Please correct the following errors:\n____________________________\n\n" + strAlertMsg);
eval("theForm." + focusField + ".focus()");
//alert(focusField);
theForm[focusField].focus();
return false;
}
return true;
}
//-->
</script>
</head>
<body class="sub">
<form id="form1" action="/508/wizard.asp" method="post" onsubmit="return validateForm(this);">
<table width="90%" border="0" cellspacing="2" cellpadding="4">
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px; height: 31px;">
<table cellSpacing="0" cellPadding="0" align="left" border="0" style="width: 713px">
<tr>
<th style="FONT-SIZE: 12px; COLOR: white" noWrap bgColor="#4682b4">
Visual Impairment Form<img height="1" src="pixel.gif" width="10" border="0" /></th>
<td>
<img height="21" src="formtab_r.gif" width="10" border="0" /></td>
<td width="100%" background="line_t.gif"> </td>
</tr>
</table>
</td>
</tr>
<tr style="vertical-align: top">
<td valign="top" nowrap="nowrap" style="width: 722px">
<p class="style2">
<label id="lblCustome_Name" for="Customer_Name" class="style2">Name</label>
<input type="text" id="Customer_Name" name="Customer_Name" class="newStyle1" tabindex="0" />
<label id="lblemail" for="email" class="style2">Please enter your email address</label>
<input type="text" name="email" id="email" class="newStyle1" tabindex="0" />
<label id="lbldDate" for="dDate" class="style2">Please enter today's date</label>
<input type="text" name="dDate" id="dDate" class="newStyle1" tabindex="0" />
<FIELDSET>
<LEGEND> Do you need a screen reader to
access your computer?</LEGEND>
<input type="radio" name="radio1" value="Yes" id="radio1y" class="style2" tabindex="0" />
Yes
<label><input type="radio" name="radio1" value="No" id="radio1n" class="style2" />
No</label>
</FIELDSET>
<p class="style2">
<label id="lblradio2" for="radio2">Do you need to hear your screen reader
while on the phone?</label>
<input type="radio" name="radio2" value="Yes" id="radio2y" class="style2" tabindex="0" />
Yes
<input type="radio" name="radio2" value="No" id="radio2n" class="style2" />
No
<p class="style2">
<label id="lblFname" for="PhoneB">What brand and model of phone do you
use?
</label>
<textarea name="PhoneB" id="PhoneB" rows="5" class="newStyle1" style="width: 373px" tabindex="0"></textarea>
<p class="style2">
<span class="style3">
<label>Do you need a braille display for reading information on your
computer?</label>
<label id="lblFname" for="radio3">
<input type="radio" name="radio3" value="Yes" id="radio3y" class="style2" tabindex="0" />
Yes</label>
<label>
<input type="radio" name="radio3" value="No" id="radio3n" class="style2" tabindex="0" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you prefer a 40 or 80 cell braille display?</label>
<label id="lblFname" for="radio4">
<input type="radio" name="radio4" value="40 cell" id="radio4y" class="style2" tabindex="0" />
40 cell</label>
<label>
<input type="radio" name="radio4" value="80 cell" id="radio4n" class="style2" tabindex="0" />
80 cell</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to access printed materials to complete your daily
assignments?</label>
<label id="lblFname" for="radio5"><input type="radio" name="radio5" value="Yes" id="radio5y" />
Yes</label>
<label>
<input name="radio5" type="radio" id="radio5n" value="No" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you need to produce hardcopy braille materials in your daily
work activities?</label>
<label id="lblFname" for="radio6"><input type="radio" name="radio6" value="Yes" id="radio6y" />
Yes</label>
<label>
<input type="radio" name="radio6" value="No" id="radio6n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have access to a shared braille embosser (printer)?</label>
<label id="lblFname" for="radio7"><input type="radio" name="radio7" value="Yes" id="radio7y" />
Yes</label>
<label>
<input type="radio" name="radio7" value="No" id="radio7n" />
No</label>
</span></p>
<p class="style2"><span class="style3">
<label>Do you have issues locating keys on your keyboard?</label>
<label id="lblFname" for="radio8"><input type="radio" name="radio8" value="Yes" id="radio8y" />
Yes</label>
<label>
<input type="radio" name="radio8" value="No" id="radio8n" />
No</label>
</span></p>
<p class="StoryContentColor style2 style3"><span class="style2">
<label>Do you need to take notes during meetings away from your desk
and/or in training sessions?</label>
<label id="lblFname" for="radio9"><input type="radio" name="radio9" value="Yes" id="radio9y" />
Yes</label>
<label>
<input type="radio" name="radio9" value="No" id="radio9n" />
No</label>
</span></p></td>
</tr>
<tr style="vertical-align: top">
<td style="width: 722px">
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
<input type="reset" id="btnReset" name="btnReset" value="Reset" />
</td>
</tr>
</table>
</form>
</body>
</html>
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 again hielo!
Open in new window