tanhaha_how
02-24-2006, 11:28 AM
hi...i'm newbie in asp....please help me!!!deadline tomorrow!!!
four fields here...
1.Bank (combo box)
2.date (combo box)
3.amount (text box)
4.email (text box)
when user leave all fields empty and clcik submit button...it should shows the error msgs in asp but not the ALERT msgs...but...now the problem is for the date's error msg will popup first...then disappear...after that, the rest error msgs will only show after the date's error msg disappear.....the text in bold(<myspan>) is for date.....
thank you in advance!!!
<!-- #include file = "../SharedScripts/include.asp" -->
<%
Response.AddHeader "Progma", "no-cache"
Response.AddHeader "cache-control", "no-store"
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
dim haha, valemail, subop2,subop6,subop8,subop10,subop15
Set objRS3 = Server.CreateObject("ADODB.Recordset")
Set objRS4 = Server.CreateObject("ADODB.Recordset")
Set objRS5 = Server.CreateObject("ADODB.Recordset")
Set objRS6 = Server.CreateObject("ADODB.Recordset")
Set objRS7 = Server.CreateObject("ADODB.Recordset")
Set objRS8 = Server.CreateObject("ADODB.Recordset")
Set objRS9 = Server.CreateObject("ADODB.Recordset")
Set objRS10 = Server.CreateObject("ADODB.Recordset")
minYear=1900
maxYear=2100
haha = request("a")
subop2 = request("subop2")
subop6 = request("subop6")
subop8 = request("subop8")
subop10 = request("bank")
c=request("amount")
d=request("email")
b=request("txtDate1")
e=request("txtDate2")
f=request("txtDate3")
valemail = true
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if haha = "passup" then
if request("bank")="none" then
subop10="empty"
end if
if request("txtDate1")="0" or request("txtDate2")="0" then
subop8="errordate"
end if
if valamount="" or valamount=false then
subop6="erroramount"
end if
txtDate3 = DatePart("yyyy", Date())
end if
%>
<html>
<head>
<SCRIPT language=Javascript>
//only allow numbers and dot(.)
function isNumberKey(evt)
{
if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode==46)))
event.returnValue=false;
}
</SCRIPT>
<script type="text/javascript">
function addMonths() {
var MONTHS=["Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "];
var today=new Date();
var thisYear=today.getFullYear();
var thisMonth=today.getMonth();
for (var x=0; x<=thisMonth; x++) { // Use this if you want January to be first
//for (var x=thisMonth; x>=0; x--) { // Use this if you want the current month to be first
var option = document.createElement('option');
option.value=thisMonth+1;
var text = document.createTextNode(MONTHS[x]+' '+thisYear);
option.appendChild(text);
document.getElementById('months').appendChild(option);
}
}
</script>
<script type="text/javascript">
var today = new Date();
var allM = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
var ty=today.getFullYear();
var tm=today.getMonth();
var td=today.getDate();
var mes ='Please, select a valid date';
var mes1 ='Please, select a date in the past';
function validate(){
var txt = document.getElementById('myspan').firstChild;
var pm = document.getElementById('months').selectedIndex-1;
var nd = document.getElementById('dates').selectedIndex-1;
if(pm<0||nd<0){txt.data=mes;return false}
var pd = Number(document.getElementById('dates').value);
var pdate = new Date(ty,pm,pd);
if(pdate.getDate()!=pd){txt.data=mes;return false}
if(pdate>=today){txt.data=mes1;return false}
}
onload = function(){
var root = document.getElementById('months');
var i=0;
while(i<=tm){
var opt = document.createElement('option');
opt.setAttribute('value',allM[i]+' '+ty);
opt.appendChild(document.createTextNode(allM[i]+' '+ty));
root.appendChild(opt)
i++
}
}
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload="addMonths();">
<center><b>Bank Payment</b></center>
<form name="form" action="clickhere.asp" method="post" onsubmit="return validate()">
<table align="center" border=0>
<tr>
<td width="88">Bank:</td>
<td width="24"></td>
<td colspan="5"><Select name="bank">
</Select><% if subop10="empty" then%><span class="red">*</span><% end if %></td>
</tr>
<tr>
<td>Payment Date:</td>
<td></td>
<td width="48"><select name="txtDate2" id="dates">
<option value="0">---</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select></td>
<td width="14" align="left">-</td>
<td width="102">
<select name="txtDate1" id="months">
<option>---</option>
</select>
<% if subop8="errordate" then%><span class="red">*</span><% end if %>
</td>
<td width="0" align="center"></td>
<td width="108">
</td>
</tr>
<tr>
<td></td>
<td></td>
<td align="center">dd</td>
<td align="left">-</td>
<td>mm, yyyy</td>
</tr>
<tr>
<td>Amount:</td>
<td>RM</td>
<td colspan=5><input type="text" name="amount" onkeypress="return isNumberKey(event)" value="<%if haha<>"cancel" then%><%=server.HTMLEncode(request("amount"))%><%end if%>"><% if subop6="erroramount" then %><span class="red">*</span><% end if %></td>
</tr>
<tr>
<td>Email:</td>
<td></td>
<td colspan=5><input type="text" name="email" size=40 value="<%if haha<>"cancel" then%><%=server.HTMLEncode(request("email"))%><%end if%>"><% if subop5="invalidEmail" or valemail = false then %><span class="red">*</span><% end if %></td>
</tr>
<tr>
<td colspan=7 align="center"><input type="button" value="Submit" onclick=change("passup");validate()>
<input type="button" value="Cancel" onclick=change("cancel")></td>
</tr>
<tr>
<td align="center" colspan=7>
<% if subop10="empty" then%>Please select a bank.<br><br><% end if %>
<% if subop8="errordate" then%>Please enter a valid date.<br><br><% end if %>
<span id="myspan"> <br><br></span>
<% if subop6="erroramount" then%>Please enter an amount.<br><br><% end if %>
<% if valemail=false or subop5="invalidEmail" then%>Please enter a valid email.<br><br><% end if %>
</td>
</tr>
</table>
<input type="hidden" name="a">
</form>
<br>
<table border="1" align="center">
<tr>
<td>
<b>IMPORTANT NOTICE</b><br><br>
Please note that activation keys will ONLY be sent to you upon receiving copies of<br>your deposit slips<br><br>
via fax<br>
Fax No.: 04-2278 718<br>
OR<br><br>
by post<br>
addressed to: Our-science.com Sdn. Bhd. (521441-V)<br>
18-13-G, Gurney Tower,<br>
Gurney Drive,<br>
10250 Penang.<br><br>
However, if you do NOT RECEIVE your activation keys 7 days after sending us<br>
your copy of deposit slips, please contact us via EMAIL at info@icdsites.com<br>
</td>
</tr>
</table>
<center>
<form action="../../../index.asp">
<input type="submit" value="Back to Main">
</form>
</center>
</body>
</html>
<script language="vbscript">
<!--
sub change(operation)
form.a.value=operation
form.submit
end sub
-->
</script>
four fields here...
1.Bank (combo box)
2.date (combo box)
3.amount (text box)
4.email (text box)
when user leave all fields empty and clcik submit button...it should shows the error msgs in asp but not the ALERT msgs...but...now the problem is for the date's error msg will popup first...then disappear...after that, the rest error msgs will only show after the date's error msg disappear.....the text in bold(<myspan>) is for date.....
thank you in advance!!!
<!-- #include file = "../SharedScripts/include.asp" -->
<%
Response.AddHeader "Progma", "no-cache"
Response.AddHeader "cache-control", "no-store"
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
dim haha, valemail, subop2,subop6,subop8,subop10,subop15
Set objRS3 = Server.CreateObject("ADODB.Recordset")
Set objRS4 = Server.CreateObject("ADODB.Recordset")
Set objRS5 = Server.CreateObject("ADODB.Recordset")
Set objRS6 = Server.CreateObject("ADODB.Recordset")
Set objRS7 = Server.CreateObject("ADODB.Recordset")
Set objRS8 = Server.CreateObject("ADODB.Recordset")
Set objRS9 = Server.CreateObject("ADODB.Recordset")
Set objRS10 = Server.CreateObject("ADODB.Recordset")
minYear=1900
maxYear=2100
haha = request("a")
subop2 = request("subop2")
subop6 = request("subop6")
subop8 = request("subop8")
subop10 = request("bank")
c=request("amount")
d=request("email")
b=request("txtDate1")
e=request("txtDate2")
f=request("txtDate3")
valemail = true
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if haha = "passup" then
if request("bank")="none" then
subop10="empty"
end if
if request("txtDate1")="0" or request("txtDate2")="0" then
subop8="errordate"
end if
if valamount="" or valamount=false then
subop6="erroramount"
end if
txtDate3 = DatePart("yyyy", Date())
end if
%>
<html>
<head>
<SCRIPT language=Javascript>
//only allow numbers and dot(.)
function isNumberKey(evt)
{
if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode==46)))
event.returnValue=false;
}
</SCRIPT>
<script type="text/javascript">
function addMonths() {
var MONTHS=["Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "];
var today=new Date();
var thisYear=today.getFullYear();
var thisMonth=today.getMonth();
for (var x=0; x<=thisMonth; x++) { // Use this if you want January to be first
//for (var x=thisMonth; x>=0; x--) { // Use this if you want the current month to be first
var option = document.createElement('option');
option.value=thisMonth+1;
var text = document.createTextNode(MONTHS[x]+' '+thisYear);
option.appendChild(text);
document.getElementById('months').appendChild(option);
}
}
</script>
<script type="text/javascript">
var today = new Date();
var allM = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
var ty=today.getFullYear();
var tm=today.getMonth();
var td=today.getDate();
var mes ='Please, select a valid date';
var mes1 ='Please, select a date in the past';
function validate(){
var txt = document.getElementById('myspan').firstChild;
var pm = document.getElementById('months').selectedIndex-1;
var nd = document.getElementById('dates').selectedIndex-1;
if(pm<0||nd<0){txt.data=mes;return false}
var pd = Number(document.getElementById('dates').value);
var pdate = new Date(ty,pm,pd);
if(pdate.getDate()!=pd){txt.data=mes;return false}
if(pdate>=today){txt.data=mes1;return false}
}
onload = function(){
var root = document.getElementById('months');
var i=0;
while(i<=tm){
var opt = document.createElement('option');
opt.setAttribute('value',allM[i]+' '+ty);
opt.appendChild(document.createTextNode(allM[i]+' '+ty));
root.appendChild(opt)
i++
}
}
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload="addMonths();">
<center><b>Bank Payment</b></center>
<form name="form" action="clickhere.asp" method="post" onsubmit="return validate()">
<table align="center" border=0>
<tr>
<td width="88">Bank:</td>
<td width="24"></td>
<td colspan="5"><Select name="bank">
</Select><% if subop10="empty" then%><span class="red">*</span><% end if %></td>
</tr>
<tr>
<td>Payment Date:</td>
<td></td>
<td width="48"><select name="txtDate2" id="dates">
<option value="0">---</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select></td>
<td width="14" align="left">-</td>
<td width="102">
<select name="txtDate1" id="months">
<option>---</option>
</select>
<% if subop8="errordate" then%><span class="red">*</span><% end if %>
</td>
<td width="0" align="center"></td>
<td width="108">
</td>
</tr>
<tr>
<td></td>
<td></td>
<td align="center">dd</td>
<td align="left">-</td>
<td>mm, yyyy</td>
</tr>
<tr>
<td>Amount:</td>
<td>RM</td>
<td colspan=5><input type="text" name="amount" onkeypress="return isNumberKey(event)" value="<%if haha<>"cancel" then%><%=server.HTMLEncode(request("amount"))%><%end if%>"><% if subop6="erroramount" then %><span class="red">*</span><% end if %></td>
</tr>
<tr>
<td>Email:</td>
<td></td>
<td colspan=5><input type="text" name="email" size=40 value="<%if haha<>"cancel" then%><%=server.HTMLEncode(request("email"))%><%end if%>"><% if subop5="invalidEmail" or valemail = false then %><span class="red">*</span><% end if %></td>
</tr>
<tr>
<td colspan=7 align="center"><input type="button" value="Submit" onclick=change("passup");validate()>
<input type="button" value="Cancel" onclick=change("cancel")></td>
</tr>
<tr>
<td align="center" colspan=7>
<% if subop10="empty" then%>Please select a bank.<br><br><% end if %>
<% if subop8="errordate" then%>Please enter a valid date.<br><br><% end if %>
<span id="myspan"> <br><br></span>
<% if subop6="erroramount" then%>Please enter an amount.<br><br><% end if %>
<% if valemail=false or subop5="invalidEmail" then%>Please enter a valid email.<br><br><% end if %>
</td>
</tr>
</table>
<input type="hidden" name="a">
</form>
<br>
<table border="1" align="center">
<tr>
<td>
<b>IMPORTANT NOTICE</b><br><br>
Please note that activation keys will ONLY be sent to you upon receiving copies of<br>your deposit slips<br><br>
via fax<br>
Fax No.: 04-2278 718<br>
OR<br><br>
by post<br>
addressed to: Our-science.com Sdn. Bhd. (521441-V)<br>
18-13-G, Gurney Tower,<br>
Gurney Drive,<br>
10250 Penang.<br><br>
However, if you do NOT RECEIVE your activation keys 7 days after sending us<br>
your copy of deposit slips, please contact us via EMAIL at info@icdsites.com<br>
</td>
</tr>
</table>
<center>
<form action="../../../index.asp">
<input type="submit" value="Back to Main">
</form>
</center>
</body>
</html>
<script language="vbscript">
<!--
sub change(operation)
form.a.value=operation
form.submit
end sub
-->
</script>