Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

NUMBER_REGEXP doesn't match on decimal input[number] value on Windows Phone 8.1 #12984

Closed
KilianSSL opened this issue Oct 1, 2015 · 3 comments

Comments

@KilianSSL
Copy link

Tested with Angular 1.4.6
After the native validators, the value in <input type="number" step="0.01"> is being validated against the NUMBER_REGEXP, before parsing it into the model. The IE on WP 8.1 (German Keyboard) displays the number keyboard with a , (comma) decimal separator. When you enter a decimal number, the value that is being internally validated against NUMBER_REGEXP still contains the comma and therefor does't match the regexp.
All other desktop/mobile browsers that i tested are using a period separated decimal value internally, eventhough the value displayed in the field might contain a , or . based on the lang-attribute set, therefor it works.

Repro to be used on WP8.1
http://codepen.io/anon/pen/PPWxOK

Current regexp used to validate
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;

Proposed regexp used to validate period and comma (used as a decimal separator in other locales)
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*([,\.]\d*)))\s*$/;
additionally, the value has to be converted to a decimal with . before parseFloat.

@Narretz
Copy link
Contributor

Narretz commented Oct 7, 2015

Thanks for reporting. Don't you think this should be reported to Microsoft as a bug, too?

@Narretz Narretz added this to the Backlog milestone Oct 7, 2015
@chpaulin
Copy link

What is the status on this? Since this is only an issue with IE the question rises if the IE implementation is wrong in this case. Does the standard specify that the browser should substitute comma for dot as Chrome and FF does? Anyhow, we need some kind of solution for this that isn't changing the angular.js file. Fallback right now is working with text input and redoing all validation our selfs and that is a really bad solution.

@Narretz
Copy link
Contributor

Narretz commented May 3, 2018

I'm going to close this issue, since

  • it's for a very old version of WP
  • it hasn't been reported by many people
  • it can be worked around by introducing another parser that converts the number-string before the number parser executes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants