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

input[type=number] doesn't respect the scientific notation #11602

Closed
stryju opened this issue Apr 15, 2015 · 9 comments
Closed

input[type=number] doesn't respect the scientific notation #11602

stryju opened this issue Apr 15, 2015 · 9 comments

Comments

@stryju
Copy link

stryju commented Apr 15, 2015

Hi.

just today, I came across a weird behavior - angular's input[type="number"] directive doesn't see scientific number notation (like 1e2) as a valid one, despite the fact, that browsers do.

is that on purpose?

@Narretz
Copy link
Contributor

Narretz commented Apr 21, 2015

Do you mean when setting on the model or in the input?

@stryju
Copy link
Author

stryju commented Apr 21, 2015

input


http://plnkr.co/edit/OFokf2VI5nOpo63kMCpT?p=preview

type in the input 1e3

  • :invalid selector does not apply
  • native form validator say everything's OK
  • angular form directive says otherwise

screen shot 2015-04-21 at 15 09 01

@stryju
Copy link
Author

stryju commented Apr 21, 2015

screenshots of failed validation - just to confirm that it works:

  • invalid value
  • empty value

@Narretz Narretz modified the milestones: Backlog, Purgatory Apr 27, 2015
@RogerJFX
Copy link

RogerJFX commented May 6, 2015

Simply change angular.js as a workaround, until it is fixed. It works for me. By the way this might already be some kind of fix. Maybe a '+' is missing, if someone wants to write e.g. 1E+12

var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE]+[-]?\d+)?\s*$/;

@Narretz
Copy link
Contributor

Narretz commented Jun 9, 2015

@RogerJFX would you mind sending a PR with this change and a test for it?

@RogerJFX
Copy link

Ok, I can do this. Anyways one issue will remain. Current browsers can not interpret the step attribute of input[type="number"], if value is in scientific notation but not step and vice versa.
So anything like this

<input type="number" step="1" value="1e2" />

will not work as expected.
As far as I remember, all browsers fail here.

@stryju
Copy link
Author

stryju commented Jun 10, 2015

works in chrome - converts to "normal" notation tho

@Narretz
Copy link
Contributor

Narretz commented Jun 15, 2015

fixed in ebd0fbb

@Narretz Narretz closed this as completed Jun 15, 2015
@zvuv
Copy link

zvuv commented Nov 15, 2015

the trick seems to be to add the decimal point. 1.0e-7 seems to work on most browsers

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

4 participants