Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TivonChen opened this issue Jun 27, 2016 · 6 comments
Closed

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

TivonChen opened this issue Jun 27, 2016 · 6 comments

Comments

@TivonChen
Copy link

TivonChen commented Jun 27, 2016

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

@jgw96
Copy link
Contributor

jgw96 commented 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!

@jgw96 jgw96 closed this as completed Jun 27, 2016
@dilhan119
Copy link

dilhan119 commented 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>

@GabrielDvt
Copy link

@dilhan119 , please, what is the type 'tel'? is it a type you created? If so, how can I create it? I put type tel here and is the same as text I guess...

@uzbekjon
Copy link

@GabrielDvt it's one of the new input types introduced in HTML5. It is similar to other newly introduced types such as number, email, etc. that you might have used.

<input type="tel" placeholder="Your phone number">

This is an HTML5 built-in type and you don't need anything extra to make use of it.

@saihanuman73
Copy link

@dilhan119 but if we use tel in the place of number, even letters are getting accepted. how to get rid of that ?

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants