|
 |
asp_databases thread: Validating a variable
Message #1 by "BIJU THOMAS" <thomasbiju@e...> on Mon, 29 Oct 2001 16:01:46
|
|
I want to validate a variable in server side script (text box )with a
variable in the client side script.
In page1.asp I have following asp code
<%
session("vUsrname")=request.form("username")
%>
In page2.as I want to check the following,
<script>
if isempty(session("vUsrname")) then
alert("You have not logged in. Pls go to Login Page")
end if
</Script>
Is this possible. If not, what is the alternative.
Message #2 by "Tim Morford" <tmorford@n...> on Mon, 29 Oct 2001 11:16:09 -0500
|
|
I am kind of confused about what you are asking but yes you can do what you
are trying to do.
if (<%=session("vUsrname")%>) == "" {
alert("You have not logged in. Pls go to Login Page")
}
if you do not want an Alert box, just do this
If Session("vUsername") = "" then
Response.redirect("Login.asp")
End if
Tim Morford
-----Original Message-----
From: BIJU THOMAS [mailto:thomasbiju@e...]
Sent: Monday, October 29, 2001 4:02 PM
To: ASP Databases
Subject: [asp_databases] Validating a variable
I want to validate a variable in server side script (text box )with a
variable in the client side script.
In page1.asp I have following asp code
<%
session("vUsrname")=request.form("username")
%>
In page2.as I want to check the following,
<script>
if isempty(session("vUsrname")) then
alert("You have not logged in. Pls go to Login Page")
end if
</Script>
Is this possible. If not, what is the alternative.
Message #3 by Kyle Burns <kburns@c...> on Mon, 29 Oct 2001 13:31:34 -0500
|
|
You would need to include qoutes around the string literal being printed for
Session("vUsrname") in order to get this to work:
if ("<% =Session("vUsrname") %>" == "")
{
...
}
=================================
Kyle M. Burns, MCSD, MCT
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: Tim Morford [mailto:tmorford@n...]
Sent: Monday, October 29, 2001 11:16 AM
To: ASP Databases
Subject: [asp_databases] RE: Validating a variable
I am kind of confused about what you are asking but yes you can do what you
are trying to do.
if (<%=session("vUsrname")%>) == "" {
alert("You have not logged in. Pls go to Login Page")
}
if you do not want an Alert box, just do this
If Session("vUsername") = "" then
Response.redirect("Login.asp")
End if
Tim Morford
-----Original Message-----
From: BIJU THOMAS [mailto:thomasbiju@e...]
Sent: Monday, October 29, 2001 4:02 PM
To: ASP Databases
Subject: [asp_databases] Validating a variable
I want to validate a variable in server side script (text box )with a
variable in the client side script.
In page1.asp I have following asp code
<%
session("vUsrname")=request.form("username")
%>
In page2.as I want to check the following,
<script>
if isempty(session("vUsrname")) then
alert("You have not logged in. Pls go to Login Page")
end if
</Script>
Is this possible. If not, what is the alternative.
Message #4 by Thomas Biju <thomasbiju@e...> on Tue, 30 Oct 2001 21:07:11 +0530
|
|
I have tried but error occured. "An exception of type Microsoft Jscript
runtime error:object expected has not handled"
What to do. Is the same thing possible in VBScript.
I have corrected my code as below.
<SCRIPT LANGUAGE=JAVAScript>
<!--
sub CheckLogin()
{
if "<% Session("UsrName")%>"=="" {
alert( "You Have not Loged in");
}
}
//-->
</SCRIPT>
At 01:31 PM 10/29/2001 -0500, you wrote:
>You would need to include qoutes around the string literal being printed for
>Session("vUsrname") in order to get this to work:
>
>
>if ("<% =Session("vUsrname") %>" == "")
>{
> ...
>}
>
>=================================
>Kyle M. Burns, MCSD, MCT
>ECommerce Technology Manager
>Centra Credit Union
>kburns@c...
>
>
>
>-----Original Message-----
>From: Tim Morford [mailto:tmorford@n...]
>Sent: Monday, October 29, 2001 11:16 AM
>To: ASP Databases
>Subject: [asp_databases] RE: Validating a variable
>
>
>I am kind of confused about what you are asking but yes you can do what you
>are trying to do.
>
>if (<%=session("vUsrname")%>) == "" {
> alert("You have not logged in. Pls go to Login Page")
>}
>
>if you do not want an Alert box, just do this
>
>If Session("vUsername") = "" then
> Response.redirect("Login.asp")
>End if
>
>
>Tim Morford
>
>-----Original Message-----
>From: BIJU THOMAS [mailto:thomasbiju@e...]
>Sent: Monday, October 29, 2001 4:02 PM
>To: ASP Databases
>Subject: [asp_databases] Validating a variable
>
>
>I want to validate a variable in server side script (text box )with a
>variable in the client side script.
>
>In page1.asp I have following asp code
><%
>session("vUsrname")=request.form("username")
>%>
>
>
>In page2.as I want to check the following,
>
><script>
>
>if isempty(session("vUsrname")) then
> alert("You have not logged in. Pls go to Login Page")
>end if
></Script>
>
>Is this possible. If not, what is the alternative.
>
>
Message #5 by Kyle Burns <kburns@c...> on Tue, 30 Oct 2001 10:56:45 -0500
|
|
You didn't put your "=" sign before Session("UsrName") to indicate that you
intend to do a Response.Write.
=================================
Kyle M. Burns, MCSD, MCT
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: Thomas Biju [mailto:thomasbiju@e...]
Sent: Tuesday, October 30, 2001 10:37 AM
To: ASP Databases
Subject: [asp_databases] RE: Validating a variable
I have tried but error occured. "An exception of type Microsoft Jscript
runtime error:object expected has not handled"
What to do. Is the same thing possible in VBScript.
I have corrected my code as below.
<SCRIPT LANGUAGE=JAVAScript>
<!--
sub CheckLogin()
{
if "<% Session("UsrName")%>"=="" {
alert( "You Have not Loged in");
}
}
//-->
</SCRIPT>
At 01:31 PM 10/29/2001 -0500, you wrote:
>You would need to include qoutes around the string literal being printed
for
>Session("vUsrname") in order to get this to work:
>
>
>if ("<% =Session("vUsrname") %>" == "")
>{
> ...
>}
>
>=================================
>Kyle M. Burns, MCSD, MCT
>ECommerce Technology Manager
>Centra Credit Union
>kburns@c...
>
>
>
>-----Original Message-----
>From: Tim Morford [mailto:tmorford@n...]
>Sent: Monday, October 29, 2001 11:16 AM
>To: ASP Databases
>Subject: [asp_databases] RE: Validating a variable
>
>
>I am kind of confused about what you are asking but yes you can do what you
>are trying to do.
>
>if (<%=session("vUsrname")%>) == "" {
> alert("You have not logged in. Pls go to Login Page")
>}
>
>if you do not want an Alert box, just do this
>
>If Session("vUsername") = "" then
> Response.redirect("Login.asp")
>End if
>
>
>Tim Morford
>
>-----Original Message-----
>From: BIJU THOMAS [mailto:thomasbiju@e...]
>Sent: Monday, October 29, 2001 4:02 PM
>To: ASP Databases
>Subject: [asp_databases] Validating a variable
>
>
>I want to validate a variable in server side script (text box )with a
>variable in the client side script.
>
>In page1.asp I have following asp code
><%
>session("vUsrname")=request.form("username")
>%>
>
>
>In page2.as I want to check the following,
>
><script>
>
>if isempty(session("vUsrname")) then
> alert("You have not logged in. Pls go to Login Page")
>end if
></Script>
>
>Is this possible. If not, what is the alternative.
>
>
$subst('Email.Unsub')
Message #6 by David Cameron <dcameron@i...> on Wed, 31 Oct 2001 09:55:33 +1100
|
|
This is a kind of long way to do this. By the time you have written the
value to the page you already know the answer on the server. So the function
could be rewritten. I am going to assume that for some reason you must have
this validation being performed in javascript.
<script language="javascript">
function CheckLogin() {
<%
If Session("UsrName") = "" Then
Response.Write "alert('You Have not Loged in');"
End If
%>
}
</script>
regards
David Cameron
nOw.b2b
dcameron@i...
-----Original Message-----
From: Thomas Biju [mailto:thomasbiju@e...]
Sent: Wednesday, 31 October 2001 1:37 AM
To: ASP Databases
Subject: [asp_databases] RE: Validating a variable
I have tried but error occured. "An exception of type Microsoft Jscript
runtime error:object expected has not handled"
What to do. Is the same thing possible in VBScript.
I have corrected my code as below.
<SCRIPT LANGUAGE=JAVAScript>
<!--
sub CheckLogin()
{
if "<% Session("UsrName")%>"=="" {
alert( "You Have not Loged in");
}
}
//-->
</SCRIPT>
At 01:31 PM 10/29/2001 -0500, you wrote:
>You would need to include qoutes around the string literal being printed
for
>Session("vUsrname") in order to get this to work:
>
>
>if ("<% =Session("vUsrname") %>" == "")
>{
> ...
>}
>
>=================================
>Kyle M. Burns, MCSD, MCT
>ECommerce Technology Manager
>Centra Credit Union
>kburns@c...
>
>
>
>-----Original Message-----
>From: Tim Morford [mailto:tmorford@n...]
>Sent: Monday, October 29, 2001 11:16 AM
>To: ASP Databases
>Subject: [asp_databases] RE: Validating a variable
>
>
>I am kind of confused about what you are asking but yes you can do what you
>are trying to do.
>
>if (<%=session("vUsrname")%>) == "" {
> alert("You have not logged in. Pls go to Login Page")
>}
>
>if you do not want an Alert box, just do this
>
>If Session("vUsername") = "" then
> Response.redirect("Login.asp")
>End if
>
>
>Tim Morford
>
>-----Original Message-----
>From: BIJU THOMAS [mailto:thomasbiju@e...]
>Sent: Monday, October 29, 2001 4:02 PM
>To: ASP Databases
>Subject: [asp_databases] Validating a variable
>
>
>I want to validate a variable in server side script (text box )with a
>variable in the client side script.
>
>In page1.asp I have following asp code
><%
>session("vUsrname")=request.form("username")
>%>
>
>
>In page2.as I want to check the following,
>
><script>
>
>if isempty(session("vUsrname")) then
> alert("You have not logged in. Pls go to Login Page")
>end if
></Script>
>
>Is this possible. If not, what is the alternative.
Message #7 by Biju Thomas <thomasbiju@e...> on Wed, 31 Oct 2001 22:58:40 +0530
|
|
I have corrected the code as follows: But still same error message is
displaying.
<SCRIPT LANGUAGE=javascript>
<!--
Function CheckLogin()
{
<% if Session("UsrName")="" THEN
response.write "alert( 'You Have not Loged in');"
END IF
%>
//-->
</SCRIPT>
David Cameron wrote:
> This is a kind of long way to do this. By the time you have written the
> value to the page you already know the answer on the server. So the function
> could be rewritten. I am going to assume that for some reason you must have
> this validation being performed in javascript.
>
> <script language="javascript">
>
> function CheckLogin() {
> <%
> If Session("UsrName") = "" Then
> Response.Write "alert('You Have not Loged in');"
> End If
> %>
> }
> </script>
>
> regards
> David Cameron
> nOw.b2b
> dcameron@i...
>
> -----Original Message-----
> From: Thomas Biju [mailto:thomasbiju@e...]
> Sent: Wednesday, 31 October 2001 1:37 AM
> To: ASP Databases
> Subject: [asp_databases] RE: Validating a variable
>
> I have tried but error occured. "An exception of type Microsoft Jscript
> runtime error:object expected has not handled"
>
> What to do. Is the same thing possible in VBScript.
>
> I have corrected my code as below.
>
> <SCRIPT LANGUAGE=JAVAScript>
> <!--
> sub CheckLogin()
> {
>
> if "<% Session("UsrName")%>"=="" {
>
> alert( "You Have not Loged in");
>
> }
> }
> //-->
> </SCRIPT>
Message #8 by Kyle Burns <kburns@c...> on Wed, 31 Oct 2001 12:27:40 -0500
|
|
If you've copied and pasted your code, then you are missing a "}" at the end
of your function.
<SCRIPT LANGUAGE=javascript>
<!--
Function CheckLogin()
{
<% if Session("UsrName")="" THEN
response.write "alert( 'You Have not Loged in');"
END IF
%>
} // <======= NEED BRACE HERE
//-->
</SCRIPT>
=================================
Kyle M. Burns, MCSD, MCT
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: Biju Thomas [mailto:thomasbiju@e...]
Sent: Wednesday, October 31, 2001 12:29 PM
To: ASP Databases
Subject: [asp_databases] RE: Validating a variable
I have corrected the code as follows: But still same error message is
displaying.
<SCRIPT LANGUAGE=javascript>
<!--
Function CheckLogin()
{
<% if Session("UsrName")="" THEN
response.write "alert( 'You Have not Loged in');"
END IF
%>
//-->
</SCRIPT>
David Cameron wrote:
> This is a kind of long way to do this. By the time you have written the
> value to the page you already know the answer on the server. So the
function
> could be rewritten. I am going to assume that for some reason you must
have
> this validation being performed in javascript.
>
> <script language="javascript">
>
> function CheckLogin() {
> <%
> If Session("UsrName") = "" Then
> Response.Write "alert('You Have not Loged in');"
> End If
> %>
> }
> </script>
>
> regards
> David Cameron
> nOw.b2b
> dcameron@i...
>
> -----Original Message-----
> From: Thomas Biju [mailto:thomasbiju@e...]
> Sent: Wednesday, 31 October 2001 1:37 AM
> To: ASP Databases
> Subject: [asp_databases] RE: Validating a variable
>
> I have tried but error occured. "An exception of type Microsoft Jscript
> runtime error:object expected has not handled"
>
> What to do. Is the same thing possible in VBScript.
>
> I have corrected my code as below.
>
> <SCRIPT LANGUAGE=JAVAScript>
> <!--
> sub CheckLogin()
> {
>
> if "<% Session("UsrName")%>"=="" {
>
> alert( "You Have not Loged in");
>
> }
> }
> //-->
> </SCRIPT>
Message #9 by "Daniel O'Dorisio" <daniel@o...> on Wed, 31 Oct 2001 12:24:22 -0500
|
|
You need to change Function to function.. Javascript is case sensitive.
You also need to add the closing curly brace "}" at the end of the
function.
Another consderation is to ad vbcrlf to the end of your response.write
line.. It will make long scripts easier to debug.
response.write "alert( 'You Have not Loged in');" &vbcrlf
Hth
Daniel
-----------------------------
Daniel O'Dorisio
daniel@o...
www.odorisio-networks.com
-----------------------------
-----Original Message-----
From: Biju Thomas [mailto:thomasbiju@e...]
Sent: Wednesday, October 31, 2001 12:29 PM
To: ASP Databases
Subject: [asp_databases] RE: Validating a variable
I have corrected the code as follows: But still same error message is
displaying.
<SCRIPT LANGUAGE=javascript>
<!--
Function CheckLogin()
{
<% if Session("UsrName")="" THEN
response.write "alert( 'You Have not Loged in');"
END IF
%>
//-->
</SCRIPT>
David Cameron wrote:
> This is a kind of long way to do this. By the time you have written
> the value to the page you already know the answer on the server. So
> the function could be rewritten. I am going to assume that for some
> reason you must have this validation being performed in javascript.
>
> <script language="javascript">
>
> function CheckLogin() {
> <%
> If Session("UsrName") = "" Then
> Response.Write "alert('You Have not Loged in');"
> End If
> %>
> }
> </script>
>
> regards
> David Cameron
> nOw.b2b
> dcameron@i...
>
> -----Original Message-----
> From: Thomas Biju [mailto:thomasbiju@e...]
> Sent: Wednesday, 31 October 2001 1:37 AM
> To: ASP Databases
> Subject: [asp_databases] RE: Validating a variable
>
> I have tried but error occured. "An exception of type Microsoft
> Jscript runtime error:object expected has not handled"
>
> What to do. Is the same thing possible in VBScript.
>
> I have corrected my code as below.
>
> <SCRIPT LANGUAGE=JAVAScript>
> <!--
> sub CheckLogin()
> {
>
> if "<% Session("UsrName")%>"=="" {
>
> alert( "You Have not Loged in");
>
> }
> }
> //-->
> </SCRIPT>
|
|
 |