View Full Version : VERY VERY URGENT(error message problem)

02-24-2006, 12:28 PM
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")


haha = request("a")
subop2 = request("subop2")
subop6 = request("subop6")
subop8 = request("subop8")
subop10 = request("bank")

valemail = true


if haha = "passup" then

if request("bank")="none" then
end if

if request("txtDate1")="0" or request("txtDate2")="0" then
end if

if valamount="" or valamount=false then
end if

txtDate3 = DatePart("yyyy", Date())

end if

<SCRIPT language=Javascript>
//only allow numbers and dot(.)
function isNumberKey(evt)

<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');
var text = document.createTextNode(MONTHS[x]+' '+thisYear);

<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;
var opt = document.createElement('option');
opt.setAttribute('value',allM[i]+' '+ty);
opt.appendChild(document.createTextNode(allM[i]+' '+ty));

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<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>
<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>

<td>Payment Date:</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>
<td width="14" align="left">-</td>

<td width="102">
<select name="txtDate1" id="months">
<% if subop8="errordate" then%><span class="red">*</span><% end if %>
<td width="0" align="center"></td>
<td width="108">

<td align="center">dd</td>
<td align="left">-</td>
<td>mm, yyyy</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>

<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>

<td colspan=7 align="center"><input type="button" value="Submit" onclick=change("passup");validate()>
<input type="button" value="Cancel" onclick=change("cancel")></td>
<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">&nbsp;<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 %>
<input type="hidden" name="a">
<table border="1" align="center">
<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>
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>
<form action="../../../index.asp">
<input type="submit" value="Back to Main">
<script language="vbscript">
sub change(operation)
end sub

02-25-2006, 03:04 AM
i change the code again to make u all expert easy to check for me.......really urgent.....help me please.....

thanks in advance

02-27-2006, 05:15 AM
Well I hope you have figured this out. Giving us 1 day to fix something like this is really diffacult. We are not getting paid for the help we provide. We need some time to sit down for a cup or coffee or Mt. Dew (the 2 programmers blood) get away from the women (or men - this involves the don't ask, don't tell rule - or there could be women programmers [:)]) and look over problematic codes.

In this case, I would have done the entire thing differently. There would be Request.Form ("someformnames") and found empty values, and then sent them back to the form that needed to be fixed with some highlighted fields.

If you have not figured it out let us know so we can start looking at it

02-27-2006, 05:35 AM
Here I actually forgot that I did something for someone else at one time:

This is a simple form that will check if field exist and will tell what fields are blank:

KEEP IN MIND THAT THIS CODE CAN BE SLIMMED DOWN ALOT! I wrote it this way for simplicity in the demonstration.

IF Request.QueryString("method") = "checkform" Then
IF Request.Form("firstone") = "" Then FirstTextForm = 2 ELSE FirstTextForm = 1
IF Request.Form("secondone") = "" Then SecondTextForm = 2 ELSE SecondTextForm = 1
IF Request.Form("thirdone") = "" Then thirdTextForm = 2 ELSE thirdTextForm = 1
IF FirstTextForm > 1 or SecondTextForm > 1 or ThirdTextForm > 1 Then
Response.Write "<center>There was a problem with your entry<br>" & vbNewLine & _
"<ol>" & vbNewLine & _
IF FirstTextForm = 2 Then
Response.Write " <li>First Field was empty</li>"
IF SecondTextForm = 2 Then
Response.Write " <li>Second Field was empty</li>"
IF ThirdTextForm = 2 Then
Response.Write " <li>Third Field was empty</li>"
Response.Write "<a href=""pagename.asp"">Go back and enter data</a>"
Response.Write "<form name=""pagename"" method=""post"" action=""pagename.asp?method=checkform"">" & vbNewLine & _
" <input type=text name=""firstone"" value=" & Request.Form("firstone") & "size=""25"">" & vbNewLine & _
" <input type=text name=""secondone"" value=" & Request.Form("secondone") & "size=""25"">" & vbNewLine & _
" <input type=text name=""thirdone"" value=" & Request.Form("thirdone") & " size=""25"">" & vbNewLine & _
" <input name=""Submit"" type=""submit"" value=""Submit"">" & vbNewLine & _
"</form>" & vbNewLine

02-27-2006, 10:41 PM
Wow, I was looking over my code there and I see some small problems:

1. If only one of the fields were left blank, then you will see an error, when you go back to re-enter the empty fields all of them will be empty.
a. You can fix this a couple of ways. Probably the easiest would be either "METHODS" i.e. <a href=""pagename.asp?field1=" & fieldone & "&field2=" & fieldtwo & "&field3=" & fieldthree & "" & vbNewLine

Something like that...

2. Create a javascript goback link (may or maynot work on certain browsers)
3. Another way is to simply create another form with hidden input fields.

Ok, maybe it doesn't matter, or maybe he didn't even use my code, maybe I am over thinking this WAY TOO MUCH. Maybe the voices in my head are not calm yet, maybe I haven't had a Mt Dew for 6 hours and it is causing my psychostick side to come out.

Oh well, have a good day :)

02-28-2006, 01:59 AM
Hey, i"m using your code.....mayb it is not what i want....But i've used this in another function....nvm...i'll fix it again...any problem i'll post a msg here...

Thank you very very much....:thumbsup: