View Full Version : Validating and passing data to next page
petertran123
09-26-2002, 02:41 PM
Hello all,
First let me explain what i'm working on. I had a link called "Click Here to Enter"
After user clicks on the link "Click Here to Enter" then the user will receive the page call "HolidayLoan.asp" with containing all the information.
***************
PriOneyearInd
TransOneYear
TransThreeMo
TransThirtyDays
***************
Here i wanted to create a validation script
<%
If Request.Form("PriOneYearInd") = N then
Response.Redirect "Decline.asp"
Elseif Request.Form("TransOneYear") < 10 then
Response.Redirect "Decline.asp"
Elseif Request.Form("TransThreeMo") <3 then
Response.Redirect "Decline.asp"
Else
Response.Redirect "HolidayLoan2.asp"
End if
%>
The problem is when i used the script above and click on the Link "Click Here to Enter" i automaticaly received Decline.asp. I don't want that.
I wanted to be able to enter HolidayLoan.asp and do validation before receiving a Decline.asp page. If user pass the validation they shall enter to HolidayLoan2.asp
Please Help me,
Thanks
whammy
09-26-2002, 05:14 PM
Well, I'm not sure what the first page looks like, but I'd probably do something like this:
<%
If Request.Form("PriOneYearInd") = "N" OR CInt(Request.Form("TransOneYear")) < 10 OR CInt(Request.Form("TransThreeMo")) < 3 then
Response.Redirect "Decline.asp"
Else
Response.Redirect "HolidayLoan2.asp"
End if
%>
Of course, this assumes you're not trying to get the length of the first two fields. If you are, use the Len() function.
:)
petertran123
09-26-2002, 06:29 PM
When i'm using your script i still not be able to get into holidayloan.asp...it turn over to decline.asp which code provide on top.....
The first page is just a link point to Holidayloan.asp's page
when people click on "Click here to enter" then take them to the holidayloan.asp. From here holidayloan needs to do a validation for passing value to next coming page..
But the problem i got is when i clicked on the link "Click here to enter" i automatically received decline.asp's page which is not right. When the link is clicked i want be able to get into holidayloan.asp and do a validation from here...
petertran123
09-26-2002, 06:33 PM
this is a link look like
<form name="temp" action="http://localhost/test/holidayloan.asp?<%= request.form("EFIN") %>" method="post">
<input type="hidden" name="EFIN" value="<%= request.form("EFIN") %>">
<a href="javaScript:document.temp.submit()">Click here to enter</a>
whammy
09-26-2002, 10:20 PM
If you want to receive the value of EFIN in the querystring, that needs to look like:
<form name="temp" action="http://localhost/test/holidayloan.asp?EFIN=<%= request.form("EFIN") %>" method="post">
petertran123
09-27-2002, 03:46 PM
let say i have a form containing all the fields below:
<form name="form1" action="holidayloan3.asp" method="post">
<input type="text" name="EFIN" value="">
<input type="text" name="PriOneYearInd" value="">
<input type="text" name="TransOneyear" value="">
<input type="text" name="TransThreeMo" value="">
<input type="text" name="TransThirtyDays" value="">
<input type="text" name="PriorYearIncome" value="">
</form>
Ok, now i wanted the script to validate for these fields above:
If Request.Form("PriOneYearInd") = "N" OR len(Request.Form("TransOneYear")) < 10 OR len(Request.Form("TransThreeMo")) < 3 OR len(Request.form("TransThirtyDays")) < 1 Or Len(Request.form("PriorYearIncome")) < $35,000 then
Response.Redirect "Decline.asp"
Else
Response.Redirect "HolidayLoan3.asp" (or approve page)
End if
*** the problem i had is everytime i click on submit button then is redirect to Decline.asp...
Here i wanted, when i click on the submit button, the form will validate and check if the value enter meet the requirement, then pass to the next screen which is Holidayloan3.asp ..
If the value enter was not met the requirement then redirect to decline.asp ...
Please help me with this...thanks for your kindness and patient..
whammy
09-27-2002, 03:57 PM
The problem is probably this:
Len(Request.form("PriorYearIncome")) < $35,000 then
You're comparing two values that have no relationship to each other...
Probably what you'd want to do is extract numbers from the entry and then compare the actual value received...
Function ExtractNumbers(str) ''''''''''''''''''''
If IsNull(str) Then str = ""
Dim enRegEx
Set enRegEx = New RegExp
enRegEx.Pattern = "\D"
enRegEx.Global = True
ExtractNumbers = enRegEx.Replace(str,"")
End Function ''''''''''''''''''''''''''''''''''''
If Request.Form("PriOneYearInd") = "N" OR len(Request.Form("TransOneYear")) < 10 OR len(Request.Form("TransThreeMo")) < 3 OR len(Request.form("TransThirtyDays")) < 1 Or CInt(ExtractNumbers(Request.form("PriorYearIncome"))) < 35,000 then
Response.Redirect "Decline.asp"
Else
Response.Redirect "HolidayLoan3.asp" (or approve page)
End if
Not tested but it should get you on the right track...
petertran123
09-27-2002, 04:46 PM
when i used your code is give me an error
Error Type:
Microsoft VBScript compilation (0x800A03F9)
Expected 'Then'
/test/HolidayLoan2.asp, line 49, column 227
whammy
09-27-2002, 11:37 PM
Can you post the files here .zipped? I'll fix them for you and post them.
Probably you didn't copy and paste the code right (it may have wrapped) or you have another error...
At the very least, post both pages of code here, please. :)
Also, that should be:
Function ExtractNumbers(str) ''''''''''''''''''''
If IsNull(str) Then str = ""
Dim enRegEx
Set enRegEx = New RegExp
enRegEx.Pattern = "\D"
enRegEx.Global = True
ExtractNumbers = enRegEx.Replace(str,"")
End Function ''''''''''''''''''''''''''''''''''''
If Request.Form("PriOneYearInd") = "N" OR len(Request.Form("TransOneYear")) < 10 OR len(Request.Form("TransThreeMo")) < 3 OR len(Request.form("TransThirtyDays")) < 1 Or CInt(ExtractNumbers(Request.form("PriorYearIncome"))) < 35,000 then
Response.Redirect "Decline.asp"
Else
Response.Redirect "HolidayLoan3.asp" '(or approve page)
End if
petertran123
09-30-2002, 01:48 PM
Dear Whammy,
Thanks for your kind response. I hope that you have a great weekend. Here is a .zip file please take a look and help me with an error..
there are 2 files in the .zip
Holidayloan.asp
Holidayloan2.asp
The first Holidayloan is containing personal information and second page is Calculating the Elligible of Tax Exempt. The problem is i still automatically redirect to Decline.asp when i hitted submit on first page.
Please help me, Thanks so much
whammy
10-01-2002, 01:17 AM
I apologize, petertran123, but I'm not personally able to look at your scripts at the moment in enough detail to provide the answer you are seeking due to extraneous circumstances.
I will peruse them at my first chance, though!
petertran123
10-01-2002, 02:30 PM
Thank you for your kind response. Please take your time. :)
whammy
10-02-2002, 12:45 PM
Ok, I have looked at the files - and the reason you are always being redirected to Decline.asp is you don't even have variables of the same name that you are validating on the first page.
"TransOneYear"
"TransThreeMo"
"TransThirtyDays"
"PriorYearIncome"
Don't exist on HolidayLoan.asp - so of course their length is going to be less than 10, etc....
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.