O.K., since I haven't received any scripts, I've simplified this question from the original (see below). Nevermind the hidden forms that appear--I've gotten rid of them, there is only one form now. How about a standard ASP validation script that will validate the text fields (email requiring "@" and numbers like phone number and ID number required to be numbers). Please write the error messages to a seperate page. Else if everything is alright--Response.write the selected radio button, the selected in dropdown list 1 and 2, and of course the contents of text fields and dropdown lists (birthdate, Dep No.).
Sorry for the hassel, points have been increased for a speedy response. Yes please use the ASP sample below for preferred format--changing anything that makes more sense.
Points are for a script that once I load to a server along with my HTML page, should run. (Yes I will have to look into getting a hold of IIS).
Thanks.
Here is the new version of the form to be validated:
html>
head>
title>Form/title>
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
/head>
body>
FORM name="ConFrm">
table border="0" cellspacing="0" cellpadding="0">
tr align="left">
td nowrap height="11">
input name="radFirst" type="radio" value=1 onclick="nextGroup(this.va
lue)">Cust
omer1
input name="radFirst" type="radio" value=2 onclick="nextGroup(this.va
lue)">Cust
omer2
input name="radFirst" type="radio" value=3 onclick="nextGroup(this.va
lue)">Cust
omer3
p>
select name="prodType" size="1" onChange="nextGroup1(this.
options.se
lectedInde
x)">
option value=" " selected> /option>
option value=" " selected>---Select From First Menu--------------/option>
option value=" " selected>---Select From First Menu--------------/option>
/select>
/p>
p>
select name="inqType" size="1" >
option value=" " selected> /option>
option value=" " selected>---Select From First Menu----------------/optio
n>
option value=" " selected>---Select From First Menu----------------/optio
n>
/select>
/p>
script>
!--
var groups = document.all("radFirst").l
ength + 1 //+ 1 if for the drop down item select...
var group=new Array(groups)
for (i=0; igroups; i++)
group[i]=new Array()
group[0][0]=new Option("---Select From the Menu Above---"," ");
group[1][0]=new Option("---Select From This 2nd Menu---"," ");
group[1][1]=new Option("mbType1","47");
group[1][2]=new Option("mbType2","46");
group[1][3]=new Option("mbType3","45");
group[2][0]=new Option("--Select From This 2nd Menu---"," ");
group[2][1]=new Option("nonType1","115");
group[2][2]=new Option("nonType2","116");
group[2][3]=new Option("nonType3","45");
group[3][0]=new Option("--Select From This 2nd Menu---"," ");
group[3][1]=new Option("baType1","115");
group[3][2]=new Option("baType2","116");
group[3][3]=new Option("baType3","45");
var temp=document.ConFrm.prodT
ype
function nextGroup(x){
for (m=temp.options.length-1;m
>0;m--)
temp.options[m]=null
for (i=0;igroup[x].length;i++)
{
temp.options[i]=new Option(group[x][i].text,gr
oup[x][i].
value)
}
temp.options[0].selected=t
rue
nextGroup1(0)
}
var questionss=document.ConFrm
.prodType.
options.le
ngth
var questions=new Array(groups)
for (i=0; igroups; i++) {
questions[i]=new Array(group[i].length)
for (j=0; jgroup[i].length; j++) {
questions[i][j]=new Array() }}
questions[0][0][0]=new Option("---Select---"," ");
questions[1][0][0]=new Option("---Select From the 2nd Menu---"," ");
questions[1][1][0]=new Option("Select From This 3rd Menu"," ");
questions[1][1][1]=new Option("mDtInq1");
questions[1][1][2]=new Option("mDtInq2");
questions[1][1][3]=new Option("mDtInq3");
questions[1][2][0]=new Option("Select From This 3rd Menu");
questions[1][2][1]=new Option("mEhInq1");
questions[1][2][2]=new Option("mEhInq2");
questions[1][2][3]=new Option("mEhInq3");
questions[1][3][0]=new Option("Select From This 3rd Menu");
questions[1][3][1]=new Option("mHsInq1");
questions[1][3][2]=new Option("mHsInq2");
questions[1][3][3]=new Option("mHsInq3");
questions[2][0][0]=new Option("---Select From the 2nd Menu---");
questions[2][1][0]=new Option("Select From This 3rd Menu");
questions[2][1][1]=new Option("nonIPInq1");
questions[2][1][2]=new Option("nonIPInq2");
questions[2][1][3]=new Option("nonIPInq3");
questions[2][2][0]=new Option("Select From This 3rd Menu"," ");
questions[2][2][1]=new Option("nonGrInq1");
questions[2][2][2]=new Option("nonGrInq2");
questions[2][2][3]=new Option("nonGrInq3");
questions[2][3][0]=new Option("Select From This 3rd Menu"," ");
questions[2][3][1]=new Option("nonTrvInq1");
questions[2][3][2]=new Option("nonTrvInq2");
questions[2][3][3]=new Option("nonTrvInq3");
questions[3][0][0]=new Option("---Select From the 2nd Menu---");
questions[3][1][0]=new Option("Select From This 3rd Menu"," ");
questions[3][1][1]=new Option("baDtInq1");
questions[3][1][2]=new Option("baDtInq2");
questions[3][1][3]=new Option("baDtInq3");
questions[3][2][0]=new Option("Select From This 3rd Menu");
questions[3][2][1]=new Option("baEhInq1");
questions[3][2][2]=new Option("baEhInq2");
questions[3][2][3]=new Option("baEhInq3");
questions[3][3][0]=new Option("Select From This 3rd Menu");
questions[3][3][1]=new Option("baHsInq1");
questions[3][3][2]=new Option("baHsInq2");
questions[3][3][3]=new Option("baHsInq3");
var temp1=document.ConFrm.inqT
ype
function nextGroup1(y){
var selRadio;
for (m=temp1.options.length-1;
m>0;m--)
temp1.options[m]=null
for (i=0;iquestions[document.a
ll("radFir
st").lengt
h][y].leng
th;i++)
{
for(k=0;kdocument.all("rad
First").le
ngth;k++)
{
if (document.ConFrm.radFirst[
k].checked
== true)
selRadio = k;
}
temp1.options[i]=new Option(questions[document.
ConFrm.rad
First[selR
adio].valu
e][y][i].t
ext,questi
ons[docume
nt.ConFrm.
radFirst[s
elRadio].v
alue][y][i
].value)
}
temp1.options[0].selected=
true
}
function nextGroup2(z){
window.location=temp1[z].v
alue
}
//-->
/script>
/td>
/tr>
/table>
p>
p>
p>
p>
First Name: input type="text" name="first_name">
Last Name: input type="text" name="last_name">
E-mail: input type="text" name="e_mail">
Phone Number: input name="area_code" type="text" size="3" maxlength="3">
input name="phone_number" type="text" size="10" maxlength="8">
p> Customer No:
input type="text" name="group_number">
ID No:
input type="text" name="group_id">
Date of Birth:
select name="birth_date">
option>1/option>
option>2/option>
option>3/option>
option>4/option>
option>5/option>
option>6/option>
option>7/option>
option>8/option>
option>9/option>
option>10/option>
option>11/option>
option>12/option>
option>13/option>
option>14/option>
option>15/option>
option>16/option>
option>17/option>
option>18/option>
option>19/option>
option>20/option>
option>21/option>
option>22/option>
option>23/option>
option>24/option>
option>25/option>
option>26/option>
option>27/option>
option>28/option>
option>29/option>
option>30/option>
option>31/option>
/select>
select name="birth_month">
option>Jan/option>
option>Feb/option>
option>Mar/option>
option>Apr/option>
option>May/option>
option>Jun/option>
option>Jul/option>
option>Aug/option>
option>Sep/option>
option>Oct/option>
option>Nov/option>
option>Dec/option>
/select>
input name="birth_year" type="text" size="6" maxlength="4">
p>DepNo.:
select name="select">
option>00/option>
option>01/option>
option>02/option>
/select>
p>Company No.
input name="textfield" type="text" size="6" maxlength="6">
PIN:
input name="textfield3" type="text" size="8" maxlength="8">
p>
input type="button" VALUE="Send Request" onClick="document.forms[co
ntactForm]
.submit();
document.f
orms[showF
orm2].subm
it()">
input name="reset" type="submit" id="reset" value="Reset">
/p>
/form>
/body>
/html>
**********PREVIOUS VERSION OF THE QUESTION************
Here is a form where the first three choices made by the user from radio buttons and drop-down menus, makes another form appear below using JavaScript.
The form above obviously doesn't need to be validated, but the second form that appears, needs to be validated.
Can someone please provide an ASP script that will perform validation on whichever form is chosen to appear below the main form--including the error messages when necessary pertinant to that form if and when chosen.
(I have included an example of the coding style I started to write).
I don't have server on my own computer and therefore unable to write and test ASP and am in a real bind at the moment! Points awarded to the script that validates the form(s) below when I take it to a borrowed computer as soon as I receive any replies.
Thank you in advance for helping.
*************SAMPLE ASP CODE STYLE*********************
**
Would like code to be explicit like this:
DIM strDate, strFirstName, strLastName, strEmail, strAreaCode, strPhone
DIM strGroupNo, strGroupId, strInquiry, strBaUsername, strBaPassword, strProviderId
DIM strPaymentPIN
strDate = ""
'Fields determined from entry form
strFirstName = ""
strLastName = ""
strEmail = ""
strAreaCode = ""
strPhone = ""
strGroupNo = ""
strIdNo = ""
strInquiry = ""
strBaUsername = ""
strBaPassword = ""
strProviderId = ""
strPaymentPIN = ""
'an error message indicating missing mandatory fields
strErrorMsg = ""
' Fields taken from form
strFirstName = Request.Form("firstName")
strLastName = Request.Form("lastName")
strEmail = Request.Form("email")
strAreaCode = Request.Form("areaCode")
strPhone = Request.Form("phoneNumber"
)
strGroupNo = Request.Form("groupNumber"
)
strGroupId = Request.Form("groupId")
strBaUsername = Request.Form("baUserName")
strBaPassword = Request.Form("baPassword")
strCompanyPIN = Request.Form("companyPIN")
strPaymentNo = Request.Form("paymentNo")
if isEmpty(strFirstName) then '(strFirstName = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>First Name/span>/li>"
end if
if isEmpty(strLastName) then '(strLastName = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Last Name/span>/li>"
end if
if isEmpty(strEmail) Then '(strEmail = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Title/span>/li>
"
end if
if isEmpty(strAreaCode) Then '(strAreaCode = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Company Name/span>/li>"
end if
if isEmpty(strPhone) Then '(strPhone = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Group Name/span>/li>"
end if
if isEmpty(strGroupNo) Then '(strGroupNo = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Group Number/span>/li>"
end if
if isEmpty(str) Then '(strGroupId = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Email/span>/li>
"
end if
if isEmpty(strBaUsername) Then '(strBaUsername = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Business Phone (including area code)/span>/li>"
end if
if isEmpty(strBaPassword) Then '(strBaPassword = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Business Phone (including area code)/span>/li>"
end if
if isEmpty(strProviderId) Then '(strProviderId = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Business Phone (including area code)/span>/li>"
end if
if isEmpty(strPaymentPIN) Then '(strPaymentPIN = "") then
strErrorMsg = strErrorMsg & "li>span class='h3'>Business Phone (including area code)/span>/li>"
end if
if NOT isEmpty(strErrorMsg) Then 'strErrorMsg > "" then
Response.Write "
p class='body'>The following fields are blank or invalid in the previous form. Please "
Response.Write "a href=JavaScript:history.go
(-1)> go back/a>"
Response.Write " and fill out the required information:UL>" & strErrorMsg & "/UL>/p>"
else