question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Input number validation and letter 'e'

See original GitHub issue

I’m submitting a … (check one with “x”)

[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

User can type letter “e” in input type=“number” fields and any value containing one or many letters “e” is considered valid. Also, having letters “e” in input breaks pattern validation.

Expected behavior I assume it is possible to use exponential notation in number inputs, but the value still should be tested as a valid number, and pattern validation still should be applied.

Minimal reproduction of the problem with instructions

http://plnkr.co/edit/1aQRuixe6f9bzN0Wf2RU?p=preview

  1. Try to type “eeeeeeeeee”. This is considered a valid number
  2. Try to type “123456”. Pattern validation works as intended and the field is invalid
  3. Now add letter ‘e’ : “123456e”. The field is now considered valid
  4. Conclusion: Letter ‘e’ is not taken in account for number validation and breaks pattern validation.

What is the motivation / use case for changing the behavior?

This is a silent failure in the validation process of number inputs, that currently needs to be manually adressed with input event handlers.

Please tell us about your environment: Windows 7

  • Angular version: 2.0.0

  • Browser: Chrome 53

  • Language: all

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
arciisinecommented, Oct 3, 2016

Per the stackoverflow link, that would explain why a single ‘e’ is allowed, but not why ‘eeeeeeee’ is allowed as that shouldn’t be a valid number. The ‘eeeeeee’ input is allowed in Chrome (with and without angular) but breaks in firefox. Firefox does not like the input with an ‘e’ unless its a single ‘e’ and followed by at least one number.

This boils down to an issue with Chrome specifically, not angular, though angular could attempt to work around it.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 9, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does the html input with type "number" allow the letter 'e ...
The E stands for the exponent, and it is used to shorten long numbers. Since the input is a math ...
Read more >
<input type="number"> - HTML: HyperText Markup Language
<input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
Read more >
How to stop the letter e being accepted in number input field.
I have a number of inputs which are purely integers namely 0 to 54. However, I can still type 'e' into the input....
Read more >
TextBox Type Number Allowing to type letter "e"
The 'e' letter refers to exponential. Using the 'e' is useful for condensing large numbers that would be otherwise tedious to type out....
Read more >
JavaScript : Checking for Numbers and Letters - w3resource
You can write a JavaScript form validation script to check whether the required field(s) in the HTML form contains only letters and numbers....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found