Enter numeric input for a mobile site

I used the CSS property "-wap-input-format" to force input of numerical input using "* N". 307This works on my SonyEricsson C702 but does not work on Windows Mobile IE, Windows Mobile with Opera or SonyEricsson P1i.

+3
source share
4 answers

My suggestion is also to add Javascript. Mobile Opera, as well as the iPhone, Minimo (mini-Mozilla) and much more can understand Javascript, at least to some extent.

function noNumbers(e) {
    var keynum;
    var keychar;
    var numcheck;    
    if(window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }

    if((keynum >= 48) && (keynum <= 57)) {
        return(true);
    }

    var good_codes = [8, 14, 15, 37, 38, 39, 40];
    for(i = 0; i < good_codes.length; i++) {
        if(good_codes[i] == keynum) {
            return(true);
        }
    }

    return(false);
}

Hope this helps! :)

metafilter.com

0
source

javascript Opera iphone, , , . "", HTML5. , .

+2

, , WCSS (WAP CSS) , , - .

- wap-input-format . , ( "2.50" ), ( : -wap-input-format: "* " ).

, ( , , ), , .

iPhones, "zip" "phone" (, ". myfield_zip" ). , , .

- , ( Javascript , ).

0
<input type='tel' /> 

Android iPhone Chrome Android. Windows Phone 7.5, Windows Phone 8, WP8 IE9.

<input type='number' /> 

, .

0

Source: https://habr.com/ru/post/1705714/


All Articles