Hi,
I have posted my code below:
Below I have various input boxes. Where i need help is, when a customer puts in their DOB in fields - dateStr1, monthStr1 and yearStr1.. then puts in their age in field - Ages, I need to validate that the age entered is correct, when the customer enters their age in the Ages field - preferably I would like this to happen as soon as their age as been inputed and not on form submit, but this isn't a must. Please can anyone help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
if(document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id];
}
}
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(p
arseInt(ap
pVersion)=
=4)) {
document.MM_pgW=innerWidth
; document.MM_pgH=innerHeigh
t; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_p
gW || innerHeight!=document.MM_p
gH) location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p
arent.fram
es.length)
{
d=parent.frames[n.substrin
g(p+1)].do
cument; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;
i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.
layers.len
gth;i++) x=MM_findObj(n,d.layers[i]
.document)
;
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_setTextOfLayer(objName,
x,newText)
{ //v4.01
if ((obj=MM_findObj(objName))
!=null) with (obj)
if (document.layers) {document.write(unescape(n
ewText)); document.close();}
else innerHTML = unescape(newText);
}
//-->
</script>
<style>
#sub1, #sub2
{
position: absolute;
left: 429px;
visibility: show;
z-index: 2;
width: 176px;
}
.style3 {
font-size: 12px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif}
</style>
<script language="JavaScript">
<!--
<!-- Begin
catnumber = 2
offset = 150
performOnchange = false
if (document.all) {
docObj = "document.all."
styleObj = ".style"
} else {
docObj = "document."
styleObj = ""
}
function openselect(subcat) {
popupselect = eval(docObj + subcat + styleObj)
popupselect.visibility = "visible"
}
function closeselect(submenu,subcat
){
popupselect = eval(docObj + subcat + styleObj)
if (submenu.selectedIndex != 0) {
popupselect.visibility = "hidden"
numchoice = submenu.selectedIndex
choice = submenu[numchoice].value
quoteForm.subcategory.valu
e = choice
CalcLivingCare()
submenu.selectedIndex = 0
}
}
function lock() {
performOnchange = false
}
function unlock() {
performOnchange = true
}
function CalcLivingCare() {
if (quoteForm.categoria.value
== "ageover") {
quoteForm.subcategory2.val
ue = quoteForm.subcategory.valu
e * (4/10)}
else
{
quoteForm.subcategory2.val
ue = quoteForm.subcategory.valu
e * (1/10)}
}
function selectSub(cat) {
for (i=1; i <= catnumber; i++) {
subcat = "sub" + i
popupselect = eval(docObj + subcat + styleObj)
popupselect.visibility = "hidden"
}
if (performOnchange == true) {
letsopen = "sub" + cat.selectedIndex
if (letsopen == "sub0") {
alert("No category selected")
choice = "- subcategory -"
quoteForm.subcategory.valu
e = choice
quoteForm.subcategory2.val
ue = choice
cat.focus()
} else {
openselect(letsopen)
lock()
}
}
}
// End -->
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
dim cday
dim cmonth
cday = day(DATE)
if len(cday) = 1 then
cday = "0" &cday
end if
cmonth = month(DATE)
if len(cmonth) = 1 then
cmonth = "0" &cmonth
end if
%>
<body bgcolor="#ffffff">
<form onsubmit="return check_form();" method="post" action="LifeLinePlusquote.
asp" name="quoteForm">
<table width="97%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td width="41%"><span class="style3">On your next Birthday will you be </span></td>
<td width="59%">
<div align="left">
<span id="sub1"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="../../Images/helpPers
onal.gif" alt="Click for Information" width="20" height="20" align="absmiddle" class="rapid1" onclick="MM_popupMsg('Plea
se note that the maximum amount of cover in Lifeline Plus is £100,000 for clients below 60 and £50,000 for clients over 60.')"></font><select name="subageunder" onchange="closeselect(this
,'sub1')">
<option selected value="0">Lifeline Sum Assured</option><% Dim counter
counter=1
for counter = 1 to 100 %><% Response.Write "<OPTION value="&CStr(counter*1000)
& ">" &CStr(counter*1000) & "</OPTION>" %><% NEXT %>
</select> </span><span id="sub2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="../../Images/helpPers
onal.gif" alt="Click for Information" width="20" height="20" align="absmiddle" class="rapid1" onclick="MM_popupMsg('Plea
se note that the maximum amount of cover in Lifeline Plus is £100,000 for clients below 60 and £50,000 for clients over 60.')"></font><select name="subageover" onchange="closeselect(this
,'sub2')">
<option selected value="">Lifeline Sum Assured</option><% Dim ccounter
ccounter= 1
for ccounter = 1 to 50 %><% Response.Write "<OPTION value="&CStr(ccounter*1000
) & ">" &CStr(ccounter*1000) & "</OPTION>" %><% NEXT %>
</select> </span><select name="categoria" onmouseover="unlock()" onchange="selectSub(this)"
>
<option value="" selected="selected">-- Age Attained --</option>
<option value="ageunder">60 or Under?</option>
<option value="ageover">Over 60?</option>
</select> <br>
</div>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="97%" height="345" border="0" cellpadding="4" cellspacing="0">
<tr>
<td height="24"> </td>
<td> </td>
<td width="3%" rowspan="15"> </td>
<td width="2%" rowspan="15"> </td>
</tr>
<tr>
<td width="41%" height="24"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Post Code</font></td>
<td width="54%"><input name="postcode1" id="postcode1" size="4" maxlength="4"> <input name="postcode2" id="postcode2" size="4" maxlength="4"></td>
</tr>
<tr>
<td height="32"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Policy Type</font></td>
<td>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><select name="Products" size="1" multiple id="Products" style="BACKGROUND-COLOR: white">
<option value="F+, FV" selected="selected">LifeLi
ne Plus</option>
</select> </font></p>
</td>
</tr>
<tr>
<td height="30"><font face="Verdana" size="2">Inception Date</font></td>
<td><font size="3"><input name="dateStr2" size="1" maxlength="2" value="<%=cday%>"> / <input name="monthStr2" size="1" maxlength="2" value="<%=cmonth%>"> / <input name="yearStr2" size="4" maxlength="4" value="<%=year(DATE)%>"> </font></td>
</tr>
<tr>
<td><span class="style3">Your Lifeline Sum Assured </span></td>
<td><input name="subcategory" type="text" id="subcategory" size="5" maxlength="5" readonly="readonly"></td>
</tr>
<tr>
<td height="30" class="style3">Your Living Care Sum Assured</td>
<td valign="middle" class="style3">£ <input name="subcategory2" type="text" id="subcategory2" size="5" maxlength="5"></td>
</tr>
<tr>
<td height="30"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">D.O.B</font></
td>
<td><font size="3"><input name="dateStr1" size="1" maxlength="2" value="01"> / <input name="monthStr1" size="1" maxlength="2" value="01"> / <input name="yearStr1" size="4" maxlength="4" value="1900"> </font></td>
</tr>
<tr>
<td height="24"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Age of Eldest Applicant</font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="Ages" size="2" maxlength="2" />
</font></td>
</tr>
<tr>
<td height="32"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Gender</font><
/td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><select name="Gender" id="Gender">
<option selected="selected">Gender
</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select> </font></td>
</tr>
<tr>
<td height="32"> </td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
</tr>
<tr>
<td height="32"> </td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
</tr>
<tr>
<td height="32"> </td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
</tr>
<tr>
<td></td>
</tr>
</table>
<div align="center">
<br>
<input name="calcpremium" type="image" src="../../Images/calculat
e.gif" alt="Calculate your premium based on the information that you have entered" width="136" height="30" border="0"><br>
<br>
</form><br>
</body>
</html>
Start Free Trial