E is allowed in type="number"

https://www.codecademy.com/courses/learn-html/lessons/form-validation/exercises/required?action=resume

Type is set to number, yet somehow e is still allowed? Is it because e is 2.71 blah blah, and it’s considerred a number?

the validation is done when you press the submit button:

e not allowed, given its not a number

1 Like

e’ is the base of the Natural Logarithms, also known as Napier’s constant (invented by John Napier).

The number ‘e’ is a famous irrational number, and is one of the most important numbers in mathematics.

In this input type attribute,

<input type="number" />

You can set restrictions on what numbers that are accepted by using one or more of this rules:

  • max - to chose the maximum value allowed
  • min - to chose the minimum value allowed
  • step - to chose the legal number intervals

And since ‘e’ is approximately equal to 2.71828. You can set rules to bypass it. But the user can still enter ‘e’ in the field because it is still considered a number.

for example:

<form action="#">
  <label for="num-1">Number:</label>
  <input type="number" name="num-1" step="10" />
  <input type="submit" />
</form>

In this code, you can add the number ‘e’ here, but It will not be validated because the restrictions.

You can read more about the Euler’s number here in Wikipedia

1 Like