Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

oTechnology

macrumors newbie
Original poster
Jan 3, 2010
13
0
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
 
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.
 
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.
 
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)
 
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 =)
 
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

Apparently, if you include "phone" or "zip" in the input field name, then the iPhone will default to the numeric keyboard.


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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.