Password protect a website

Discussion in 'Web Design and Development' started by oTechnology, Feb 23, 2010.

  1. oTechnology macrumors newbie

    Joined:
    Jan 3, 2010
    #1
    Hey guys and gals,

    so firstly I need to password protect a page using either Javascript or HTML, I have found a Javascript password protection script, but I want it to work on an iPod touch, and I want it to make it a passcode not a password, and it would show the numeric pad on the iPod touch and not the alpha-numeric qwerty layout, like the numeric pad you get when you password your iPod or iPhone,

    I tried setting the code to show only numbers from 0-9 but still doesn't show the numeric pad on the iPod touch.
    HTML:
    <script language="Javascript">
    
    <!--
    
    var password = "test"
    var x = prompt("Enter in the password "," ")
    if (x.toLowerCase() == password) {
    alert("Come right in \n \n You've entered in the right password")
    location = "index.htm"
    }
    
    else {
    location = "bad.htm"
    }
    
    //-->
    
    </script>
    this is the exact same as the script i am using, but this is an example one, can someone please edit the code given so you can solve my problem.

    Thanks
     
  2. splitpea macrumors 6502a

    Joined:
    Oct 21, 2009
    Location:
    Among the starlings
    #2
    Anything password protected with javascript can be broken into by anyone with a web browser and a modicum of web dev experience.

    There is no such thing as password protection using HTML.

    There is password protection using web server configuration or any of a number of scripting languages such as PHP, Perl, Python, ASP, Ruby... etc.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    JavaScript enforced password protection doesn't amount to any security. If you want a properly password protect, use either a .htaccess file or some PHP (or other server-side language). Bypassing a JavaScript protection scheme is trivial.

    I don't know of a way to have JavaScript tell the device (iPhone) that it should only provide digits for entry. You could put up a custom numeric keypad with HTML though. I've built custom calculators that way. Just make the buttons big enough for a finger and make the entry field read-only and have JavaScript enter the numbers into the field.
     
  4. designguy79 macrumors 6502

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #4
    Don't forget about HTTPS, too, otherwise your password is easily "sniffed" by anyone else on the same network (and networks in between, but that seems less likely to be a problem in my mind)
     
  5. koruki macrumors 6502a

    koruki

    Joined:
    Aug 16, 2009
    Location:
    New Zealand
    #5
    like other said, if its on an apache server you can use .htaccess and MD5 to have a pretty secure login

    Out of curiosity can you please point us to the site you found this so called js password security script =)
     
  6. needlnerdz macrumors regular

    needlnerdz

    Joined:
    Jun 10, 2006
    Location:
    switzerland
    #6
    just googled 'form only numbers iphone'

    first link brought me here, which has your answer:

    http://www.bennadel.com/blog/1197-Defaulting-To-The-Numeric-Keyboard-On-The-iPhone.htm


    There's your answer. Repeating what everyone else is saying.. you really need to use a serverside password/code. .htaccess would force the whole keyboard to appear and ask for a login + pass... but just do some searches for how to do a simple PHP $_POST password or login.. and you should find all that you need to make a simple form on the page [also look into focusing the browser on this particular element in the bodys onLoad trait...] and you'll get your fancy numeric pad form. Phew!


    good luck!
     

Share This Page