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.

bug: Input type number is not respected

See original GitHub issue

Type: <span ionic-type>bug</span>

Ionic Version: <span ionic-version>2.x</span>

Platform: <span ionic-platform>all</span>

<span ionic-description>Steps to reproduce:

  1. Create an ion-input with type="number"
  2. Add [(ngModel)] and (ngModelChange) to get the Value of the input
  3. Check the type of the value using typeOf(value)
  4. Type in a number into the input => Type is always a string

Expected behavior: … => Type is a number.

See this plunk as an example: https://run.plnkr.co/plunks/GHBFad/</span>

<span is-issue-template></span>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:28 (12 by maintainers)

github_iconTop GitHub Comments

11reactions
brandyscarneycommented, Jan 24, 2017

I confirmed this is still an issue with latest.

4reactions
dpsoftcommented, Nov 22, 2016

workaround:

Template:

 <ion-input 
    type="number" 
    [ngModel]="progress" 
    (ngModelChange)="progress = convertToNumber($event)">
  </ion-input>

Function:

public convertToNumber(event):number {  return +event; }

hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: Input type number is not respected · Issue #7121 - GitHub
Ideally, the input value property should be string | number and not just string . And the data returned to the handler should...
Read more >
Chrome/HTML5: Input type number not respecting max ...
Chrome/HTML5: Input type number not respecting max attribute? · Works fine for me, I get the error message "Value must be less than...
Read more >
Why the number input is the worst input - Stack Overflow Blog
When the number input contains an invalid value and you retrieve the value, you get a blank string ... If you are building...
Read more >
Bug found: Form - no validation for input field type: "Number"
When you set an inputfield type to "Number", and submit the form without a valid number, no validation is made, no error message...
Read more >
HTML5 Form Validation With the “pattern” Attribute - Web Design
Whenever the value given is not met with the expected formatting, these input types will throw an error message thus preventing submission.
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