Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Popup 1

Status
Not open for further replies.

jshurst

Programmer
Joined
Oct 27, 2004
Messages
1,158
Location
US
I found the following code online. I can get the popup to work, but if the username and password are wrong it doesn't do anything. I would like another box to popup telling you that it is wrong. I really know nothing about JS, so any help would be appreciated.
Code:
<script language="javascript">
function CallScript(){ 
var username = prompt("Enter Username In the Box Below","")
var password = prompt("Enter Password In the Box Below","")

if (username !="admin" || password !="secret")
{ top.location="about:Bad Username and/or Password" };}
</script>
 

Change this:

Code:
top.location="about:Bad Username and/or Password"

to this:

Code:
alert('Bad Username and/or Password');

Hope this helps,
Dan

 
It works but now I am having another problem. I would like this to be like a confirmation box. (I am also working with ASP.NET). If the user enters the wrong password then I don't want the page to postback. It the right one is entered then I would the page to continue with the postback. This code posts back no matter what. Can someone help me or explain this? thanks.
 

I could guess at what to do, but to be sure, you should post the code that calls the CallScript function, and/or the form that get submitted.

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top