|
-
Jun 27th, 2001, 11:04 AM
#1
Thread Starter
Lively Member
Submit asp page
What is the best way of doing my validation:
I have 2 asp pages: asp_page1, asp_page2
I have 3 text boxes in asp_page1 and 1 Submit button.
Once the values are entered in all three text boxes, I press the submit button and the data is submitted to asp_page2.
In asp_page2, I have 3 recordsets.
Rec1 is based on values from textbox1 and textbox2
Rec2 is based on values from textbox1 and textbox3
Rec3 is based on Rec1 and Rec2
My question is:
1) How can I show a message, when Rec1 or Rec2 is null and redirect then to asp_page1. Do I have to write a script or can I just use response.write "...."
I tried the following code:
If Rec.RecordCount = 0 or Rec1.RecordCount= 0 Then
Response.Write "....."
Response.Redirect "asp_page1.asp"
End if
This code gives me an error.
2) Can I check the value for Rec1 and Rec2 in asp_page1 and then submit it to asp_page2. How can I do these??
Thanks
Reggie
-
Jun 27th, 2001, 11:49 AM
#2
Frenzied Member
the best thing to do would be
to make all the possible validation before goiing to the server,
do something like
in your form tag put:
onSubmit="return validation();"
and your function would be:
<script language="javascript">
function validation(){
make all your verification
and then, if everything is ok
return true
else
return false
}
</script>
here's an example of one of my validation!!
Code:
function validation(){
var msg='';
if(document.info.email.value.length==0){msg+='Your Email\n';}
if(document.info.fname.value.length==0){msg+='Your First Name\n';}
if(document.info.lname.value.length==0){msg+='Your Last Name\n';}
if(document.info.password1.value.length==0 || document.info.password2.value.length==0)
{
msg+='Your Password\n';
}else{
if(document.info.password1.value != document.info.password2.value){msg+='Password don\'t match\n';}
}
if(msg == ''){
return true;
}else{
alert(msg);
return false;
}
-
Jun 27th, 2001, 12:07 PM
#3
Frenzied Member
Re: Submit asp page
Originally posted by vkallelil
[1) How can I show a message, when Rec1 or Rec2 is null and redirect then to asp_page1. Do I have to write a script or can I just use response.write "...."
I tried the following code:
If Rec.RecordCount = 0 or Rec1.RecordCount= 0 Then
Response.Write "....."
Response.Redirect "asp_page1.asp"
End if
This code gives me an error.
2) Can I check the value for Rec1 and Rec2 in asp_page1 and then submit it to asp_page2. How can I do these??
Thanks
Reggie
Well, I'm not going to tell you the best way. TIAMTOW.
But if you want to do validation before they press submit, you will have to do that with client side code. If you want to keep this in server side code, that is very doable.
What kind of error are you getting? Why are you writing before the redirect? You don't have to write anything, just redirect.
Something we do on this project is check for a Session("errMessage"). If there is one, we show it in red.
Code:
<%
if Session("errMessage") <> "" then
Response.Write("<font color='#ff0000'>" & Session("errMessage") & "</font>")
end if
%>
And before the redirect, you can set the session variable, so when they go back to the first ASP (and they don't realize that they left that page since they don't see the second ASP) it will now read "Enter a valid number." or whatever.
Make any sense?
So, what is that error you are getting?
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 27th, 2001, 12:41 PM
#4
Thread Starter
Lively Member
Thanks Sebs,
That would be one portion of my validation.
But, I have to find the value of my Rec1 and Rec2, see if the value is not null then submit the form (asp_page1). Is that possible??
Reggie
-
Jun 27th, 2001, 12:45 PM
#5
Thread Starter
Lively Member
Hi Travis,
This is the error messge:
Response object error 'ASP 0156 : 80004005'
Header Error
/Inventory_Error_Data/asp_page2.asp, line 125
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
-
Jun 27th, 2001, 12:47 PM
#6
Frenzied Member
Okay, I run into that error when I set something like Response.Expires after I start the HTML tags. Try to avoid the write before the redirect.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 27th, 2001, 12:54 PM
#7
Hyperactive Member
I usually use response.write to show an invalid data entry.
Such as:
Code:
if Rec.eof then
response.write "rec not valid"
elseif Rec1.eof then
response.write "rec1 not valid"
else
response.redirect "yoururl"
end if
Hope this helps.
-
Jun 27th, 2001, 01:26 PM
#8
Frenzied Member
your http error is because you did something like:
<html>
<dsdsdkhs
dslakh dksahdk
bla bla bla
and then start your asp
<%
redirect...
%>
instead do:
<%
redirect...
%>
and after, is ok, put your html!!
<html>
<dsdsdkhs
dslakh dksahdk
bla bla bla
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|