Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Password mask

  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password mask

    I have a password protected page but want to mask the output when entered. Now it prompts for password but shows the input.

    Please advise how I can do this:
    Code:
    var password = prompt("Enter your password","");
    if (password == "hotsource") {
    alert("Password accepted! Loading page...");
    
    document.write("<p>data here.</p>");
    
    }
    
    else {
    alert("" +password+ " is an Invalid Password! Access denied...");
    
    document.write("<p><b>You have entered an invalid password. ");
    document.write("Access to the document is denied.</b></p>");
    }

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Regular Coder
    Join Date
    Sep 2005
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a reason why you want to use strictly JS?
    How about HTML:
    Code:
    <intput type='password' onchange='validate(this.value)' />
    If you want answers, write a smart question.

    Yes, someone probably does know how...

    Oh, and if you want to learn, STFW!

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,619
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You will have to make your own equivalent to the prompt box that uses a password field. There isn't one built into Javascript. See http://javascript.about.com/library/blmodald1.htm for an example of one way to do it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •