Grow your CSS skills. Land your dream job.

Javasript show/hide with password

  • # March 23, 2012 at 12:44 pm

    Hi everyone,

    I have a basic java script code to show and hide a div element. What I want to do is to make the element hide only when a password is entered.

    Here’s what I am aiming to do: Basically I want to cover my website with a div element 100% width and height, with a message saying the website is in development. And I want to set a pass code which can be entered to hide the div element and be able to use the website.

    Ok, so the code I have is:

    Click here

    Now you see me


    From: http://www.javascriptkit.com/javatutors/dom3.shtml

    I’d be grateful if anyone can help me.
    Thanks
    Aleksander

    # March 23, 2012 at 3:35 pm

    Hmm..

    I’d use PHP with a isset function. Besides, JS could be off in the browser and it wouldn’t work.

    # March 23, 2012 at 5:44 pm

    >>Besides, JS could be off in the browser and it wouldn’t work. < <
    true, forgot about that.

    I’m not very good in php, how to use the isset function?

    # March 23, 2012 at 8:35 pm

    Also someone looking at your JS could easily find the password
    There’s a million and one ways to do this with PHP

    A very simple way would be to use AJAX to post the password to a PHP file and just use an if statement to compare the POST data with the password before returning the details

    # March 24, 2012 at 6:03 pm

    Ok, thanks will try this AJAX and PHP method. If I’m lost or confused I’ll come back here…lol

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".