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.

ion-input with type "number" conflicts with maxlength attribute

See original GitHub issue

Short description of the problem:

ion-input with type “number” conflicts with maxlength attribute, so that the number of characters we input can be more than maxlength. Change type to “tel”, everything will be ok.

Steps to reproduce:

  1. Add ion-input with type ‘number’ and set maxlength=“10”
  2. Enter more than 10 numbers
<ion-item>
  <ion-label>phone</ion-label>
  <ion-input type="number" maxlength="10" clearInput [(ngModel)]="userPhone"></ion-input>
</ion-item>

Other information: Checked on Chrome browsers and on Android 6.0.

Which Ionic Version? 2.0.0-beta.9

Run ionic info from terminal/cmd prompt: (paste output below) Cordova CLI: 6.2.0 Ionic Framework Version: 2.0.0-beta.9 Ionic CLI Version: 2.0.0-beta.32 Ionic App Lib Version: 2.0.0-beta.18 OS: Mac OS X El Capitan Node Version: v5.11.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

21reactions
dilhan119commented, May 16, 2017

my solution is put input type as a “tel”, Because maxlength work with input type as a text & telephone number in ionic 2.

<ion-item> <ion-label>phone</ion-label> <ion-input type="tel" maxlength="10" clearInput [(ngModel)]="userPhone"></ion-input> </ion-item>

2reactions
jgw96commented, Jun 27, 2016

Hello, thanks for opening an issue with us! The maxlength attribute is not supported by the number type input. If you would like more info on why and some workarounds feel free to check out this Stack Overflow post. Thanks for using Ionic!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic-3 ion-input maxlength attribute not working
According to this post: maxlength ignored for input type="number" in Chrome. Maxlength doesn't work on input type="number".
Read more >
Where is maxLength on ion-input? - Ionic Forum
When I debug and deploy to Android device I can enter unlimited characters in the ion-input. it's like the maxlength attribute is ignored...
Read more >
Ionic Framework - Ionic Forum
<ion-input text-center autofocus="true" type="number" ... But i see that autofocus & maxlength & minlength have no effect Image may be NSFW.
Read more >
HTMLTextAreaElement - Web APIs | MDN
maxLength, long: Returns / Sets the element's maxlength attribute, indicating the maximum number of characters the user can enter.
Read more >
ion-input decimal
Store the number as inputted, and format using the decimal pipe when ... of the problem: ion-input with type "number" conflicts with maxlength...
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