1

According to the documentation, validation keys for an:
<input type="number" required />
are: required and number.

Let's recall that a key's value to true means key in error and false means fulfilling the expectation.

  • If I enter nothing, required: true and number:false => why not number as true since empty string isn't a number?
  • If I enter fergrg, required: true and number:false => why not required to false and number to true?

The only case where it seems logic is when I enter a number, where both required and number get false.

The provided demo in the documentation confirms this rule.

Bug? Or any explanation?

3
  • At a glance, it seems a number input can only ever have a value that is a number. - If you type a string into the demo in the docs, you'll notice the value remains null, so you can't ever have a value which would fail the "number" test. Commented Dec 11, 2013 at 16:06
  • @OddEssay Yes, but whatever the mechanism in background is, it really makes no sense to let the number key to false when letters are entered. Commented Dec 11, 2013 at 16:21
  • 1
    I do sort of agree, except it's a HTML thing, not an Angular thing. The value of the input type="number" is only ever a valid number, or blank. When you enter a string into the text box, the actual value evaluates to a null string, and it's the actual value that is tested, not the content of the box. Like wise, if you use jQuery to set the value with $(':input[type="number"]').val('moo'); You'll see the input box becomes blank, because the string is rejected. Commented Dec 11, 2013 at 16:35

1 Answer 1

1

This is bug. You can check it out in firefox. the $error of number should be true. Visit https://groups.google.com/forum/#!msg/angular/pRc5pu3bWQ0/4yxCdCz1JeMJ

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.