Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Limiting Fields to Numeric on Mobile Sites

How do you make it easier for a phone user to enter 12.34 for example?

8:22 pm on Oct 27, 2007 (gmt 0)

New User

5+ Year Member

joined:Oct 20, 2007
posts: 9
votes: 0

I've created a mobile website that relys on people entering numbers into form fields. While this is not too difficult using a QWERTY keypad, for those of us with 12-key keypads, entering a number like 12.34 can be annoying because to enter a "1" I have to press the "1" key about 10 times, and for the 2, 3, and 4, I have to press the button 4 times each.

Many phones (if not most) have a way to switch to a "number mode", but at least on my phone, the number mode doesn't let you enter a decimal point "." So that means I would have to waste 9 button presses to switch into, then out of, then back into number mode.

I suppose expert text messagers may not care about this, but I'm not an expert text messager, nor do I plan to be.

What I have done so far to make it faster to enter values is to allow so-called "telenumeric" entries, in which you could enter the value "!a.dg" to represent "12.34" or "dEt" to represent "3E8" (the speed of light in case you were wondering).

I created the following script to do the conversion from "telenumeric" to numeric:

function tonum($v) {
if (!is_numeric($v) ) {
$v = eregi_replace("[#\$\s]","",$v); // strip spaces, $, #
$v = eregi_replace("[a-c]","2",$v);
$v = eregi_replace("[df]","3",$v);
$v = eregi_replace("[g-i]","4",$v);
$v = eregi_replace("[j-l]","5",$v);
$v = eregi_replace("[m-o]","6",$v);
$v = eregi_replace("[p-s]","7",$v);
$v = eregi_replace("[t-v]","8",$v);
$v = eregi_replace("[w-z]","9",$v);
$v = eregi_replace("[^a-z0-9.,-]","1",$v);
return $v;
} else {
return $v;

I'd be interested in feedback on this technique, or if there is a better way to make it easier to enter numbers into form fields on a mobile site, I'm all ears.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members