Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input type "number" not working as expected in Microsoft Edge

I have an input field as follows

<input class="calc-parameter" type="number" placeholder="" 
data-parameter-name="NUMERIC" maxlength="12" id="NUMERIC-2-0">

On all browsers, I am getting the spinner and/or the keyboard is only allowing numbers to be entered

On Microsoft Edge, the user can enter numbers or characters into the field. Is there another property I need to add for Edge to consider this a numeric field only? Or is this a known Edge bug? I could not find anything on the Microsoft forums

like image 518
Mike Avatar asked Dec 13 '17 08:12

Mike


2 Answers

They claim its supported: https://caniuse.com/#feat=input-number but does not include the spinner feature.

However there is a bug filed in that the functionality doesn't work: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10792541/

Ran into this one myself.

like image 70
Gardner Avatar answered Oct 05 '22 20:10

Gardner


I know I'm late to the party but if someone is still looking for a workaround in Jquery whilst Edge catches up with google:

$('input[type=number]').on('keypress', function (e) {
// Add whatever keys you want to the condition (48-57 = numbers)
    if (e.keyCode < 48 || e.keyCode > 57) { 
        e.preventDefault();
    }
});
like image 43
C0deJack Avatar answered Oct 05 '22 22:10

C0deJack