codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



Home » Javascript » Article

Javascript Scripted Password Entry Login

Article by: Drew Bowman (1/6/2003)
Bookmark us now! Add to Favourites
Email a friend!Tell a friend
Sponsored by: FindMyHosting - Web Hosting Search
Summary: Create a password protected page using this neat javascript prompt.
Viewed: 48763 times Rating (56 votes): 
 3.5 out of 5
 Rate this Article  Read Comments  Post Comments

Javascript Scripted Password Entry Login

Live Demo

Whilst it may not be the top level of security, this javascript prompt login will protect your page from all but the most web-savvy of users.

Begin by placing the following code in the head of your document:

Select All Code


In the body tag of the page place the following:

Select All Code


Then amend the LogIn function as required based as shown below:

Select All Code







CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'Javascript Scripted Password Entry Login'
Posted by :  Archive Import (anusha) at 06:08 on Monday, January 27, 2003
Good!!
Posted by :  Archive Import (Drew Bowman (Creator)) at 15:55 on Monday, February 03, 2003
Find extended resources for this script at my newly created site at: http://drewsdesigns.tripod.com/Services.login.htm (PLEASE NOTE THAT MY SITE SERVER IS CASE SENSITIVE !!!)
Posted by :  Archive Import (Rgrego) at 12:07 on Tuesday, February 11, 2003
works like a charm. If user clicks cancel though--you get an ugly script error
Posted by :  Archive Import (Rgrego) at 16:17 on Tuesday, February 18, 2003
Hello-
This works very well-but how can I get the password prompt to display only asterisks instead of the letters the user types?


Thanks.
Posted by :  Archive Import (Drew Bowman (Creator)) at 21:55 on Saturday, March 15, 2003
This was EMailed to me in regard to setting the password field as displaying asterisks:

What I did was use a page with a basic text box web control in asp.net set to password for input. This made the asterisks appear instead of text when a user is typing into it......


here is the vb:
Dim pass As String = TxtPassword.Text.ToLower
If pass = "life" Then Response.Write("<script>window.location=" & Chr(34) & sUrl & Chr(34) & " ;</script>")
If pass <> "life" Then Response.Write("<script>alert(" & Chr(34) & "Login failed!\n\nPlease click OK, --\n\n and supply new credentials ." & Chr(34) & ");</script>")

here is the html:
<asp:TextBox id="TxtPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:Button id="BtnClick" runat="server" Text="Click"></asp:Button>
Posted by :  Archive Import (Thomas Mlynarczyk) at 12:59 on Thursday, April 17, 2003
1) All it takes is a look at the source code to read the user id and password - one might as well leave the key in the lock and just cover it with a paper bag.

2) To have asterisks displayed while typing the password, there is an <input type="password"> I think (not sure about the syntax, haven't used it for ages).

3) A more secure system would be using the password as the filename of the page to be protected:

<input type="password" onchange="self.location.href=this.value+'.html'">

(Not tested, just meant to illustrate the principle. Drawback: a wrong password will yield a 404 error.)
Posted by :  Archive Import (Hywel) at 14:19 on Thursday, April 17, 2003
This is the dumbest security script I've ever seen. Anyone using this deserves to have their stuff nicked.

You lot ought to be ashamed of yourselves for publishing this.
Posted by :  Archive Import (cjr) at 15:33 on Thursday, April 17, 2003
This is pretty foolish. Putting your password in the JS is just asking for trouble.
Posted by :  Archive Import (Drew Bowman (creator)) at 17:54 on Sunday, May 04, 2003
For those of you concerned about security there is an alternative solution. The use of a HTML encrypter (Made by Svetlin Staev found on dynamicdrive.com and cgiscript.net) is a solution, and the addition of the no right click script within a window without status / location / directories / menubar. If you are overly concerned over security run you file(s) over a secure server (https://), find a ASP variation of this script, or use this script as a "agreement of terms" verification
Posted by :  Archive Import (Derrick) at 16:04 on Friday, May 23, 2003
Question How do I get it to Go After the user has put in the password then they go to the next link?
Posted by :  Archive Import (Dave Howey) at 16:52 on Friday, May 23, 2003
It works very well. However, it would be more user friendly if both the login and password were displayed on the screen at the same time. Is there a way to do this?
Posted by :  Archive Import (Ace) at 09:56 on Tuesday, May 27, 2003
As noted, putting the login and password information in the source is quite ridiculous! Why bother with security then...even the most entry level user can view source.

At least make an ASP validation page that redirects upon submittal, that way it will be server side....still not full proof...but at least not client side!
Posted by :  Archive Import (orbach) at 13:25 on Thursday, June 05, 2003
This is not a solution but a tremendously huge security flaw. There is no way to do client side login safely. The only safe way is to check the password on the server. Having said that, you can collect the username and password using client side javascript but you *have* to post the two pieces of data such that the server will do the validation. You can do this by saving the data into your document and then doing a post.
Posted by :  Archive Import (admiral_angel) at 08:36 on Tuesday, July 08, 2003
Brilliant !!!
Posted by :  Archive Import (ss surfer) at 08:37 on Tuesday, July 08, 2003
well done, but a can be improved...
Posted by :  Archive Import (ME) at 03:21 on Wednesday, July 30, 2003
Hi, my site uses frames. I need to know how to get this password thing to load pages in the _bot Frame


Email me with a subject line of Frame on page



Thanks!
Posted by :  Archive Import (Vipin Kumar Bharadwaj) at 05:34 on Thursday, September 11, 2003
One of the best !!!!
very usefull & easy to use !!
Posted by :  Drew Bowman at 21:10 on Thursday, October 02, 2003
Due to CoadToad Member Integration I can not email you 'ME' however the answer to your question is at http://drewsdesigns.8k.com/Services.login.frames.htm .


-- Original Message --

Hi, my site uses frames. I need to know how to get this password thing to load pages in the _bot Frame


Email me with a subject line of Frame on page



Thanks!
Posted by :  ferdy_snake at 06:52 on Wednesday, February 11, 2004
easy to read and edit, but not useful security-wise
Posted by :  Drew G. Bowman at 23:04 on Thursday, February 19, 2004
The newest version of this script is available at: [b]http://www.drewsdesigns.8k.com/Services.login.htm,[/b]

<Added>

PAGE CHANGED TO: http://www.drewsdesigns.8k.com/JS.login.htm
FULL PAGE HTML: http://www.drewsdesigns.8k.com/Help.javascripts.htm
Posted by :  gabayronr at 11:42 on Wednesday, March 31, 2004
pls. tech me how to makes html password protect my website.
Posted by :  Boogalou at 17:37 on Friday, April 02, 2004
please tell me how to use the nwe version of this code!!! I don't get it!
Posted by :  Drew G. Bowman at 18:51 on Sunday, August 08, 2004
For those how have asked how to use this script use the following links this WILL be my last post unless a notification of a new version:



Version 2.0 Wizard: http://drewsdesigns.8k.com/WZ.login.htm
Version 2.0: http://drewsdesigns.8k.com/JS.login.htm
Version 2.0 Help: http://drewsdesigns.8k.com/Help.javascripts.htm#js_login
Version 2.0 Help (Email used to help a user): http://drewsdesigns.8k.com/Help.JS.login.txt
Version 1.0 (Archive): http://drewsdesigns.8k.com/Archive.login.htm
Email for questions: webmaster@drewsdesigns.8k.com
Posted by :  pooja at 15:30 on Wednesday, March 23, 2005
gr8 work..

i am just trying to write a code in jsp and pl/sql for authentication purpose ..given the username and password it has to check with the database and then accordingly shld. go to sucessful login page! or try again page ..how do i code that ?please help me..!!!

thankyou
pooja


To post comments you need to become a member. If you are already a member, please log in .

 



RELATED ARTICLES
Javascript Onload Event
by Jeff Anderson
Sometimes you need to perform an action immediatley after the page has loaded. That's when the onLoad Event Handler comes in handy
Javascript - Enable and Disable form elements
by Jeff Anderson
This is a relatively little known and under-used feature of javascript which can be very useful in guiding a user through a form. Using the disabled tag, you can switch on and off elements in a form.
Form Validation Function
by Jeff Anderson
A javascript validation function that you can use to validate all types of forms.
Check IsNumeric Function
by Jeff Anderson
A javascript validation function to check whether the details entered by a user are numeric.
JavaScript Field Is Empty Form Validation
by Jeff Anderson
This javascript function allows you to check whether a form field has been completed or not.
Check Email Validation Function
by Jeff Anderson
A javascript validation function to check whether the user has entered a valid email address in a form.
Multiple submit buttons on a single form
by Kiran Pai
This script shows you how to submit the contents of a form to different programs depending on which Submit button you press. Additionally it also shows how to call two different functions when you press the Submit button.
Validate Form and Disable Submit Button
by Marylou Marks
I have a form that validates info, but I also want to disable the submit button. The disable part worked before adding the form validating.
Simple date validation
by Chris Hogben
function that takes a date in three parts, day, month and year - returns true if it's a valid date.
Multiple submit buttons with form validation
by Paul Eckert
This code shows how to redirect a user to multiple sites, depending on which submit button he presses, but only after the form validates correctly.








Recent Forum Threads
• Re: sorting and Linked list
• Re: need help linked list
• Re: Help with arrays
• Re: Reading from a file
• Re: Why Use Method?
• Re: Help with a simple program
• Re: need help with quiz
• Re: Help with filesystem object & displaying in a table
• Re: Genetic Algorithm Help


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005