Cleave.js: Dynamic input type for React component

Created on 21 Aug 2017  路  7Comments  路  Source: nosir/cleave.js

Hi @nosir, thank you so much for this useful library!
Could you also improve it to allow dynamic input type?
For example, it could be great if in CreditCard mode user can see numeric keyboard on mobile.
Thanks in advance.

resolved

Most helpful comment

Hey @nosir I was actually able to get this to work by just adding the type attribute to my cleave component like this:

<Cleave
      placeholder="Phone Number"
      name="phonenumber"
      type="tel"
      options={{
              numericOnly: true,
              delimiters: ['-', '-'],
              blocks: [3, 3, 4],
          }}
      onChange={this.handleInputChange.bind(this)}
   />

Hope this helps.

All 7 comments

Hi, thanks for the like.
Does it show numeric keyboard with the demo in homepage for you? It is using type="tel"

It has type "text" there: https://jsfiddle.net/nosir/gLLsrxxf/
I use React, and input type "text" is hardcoded in Cleave.react.js (line 340).
I think it would be great if you will add relevant props for this feature :)

I also use cleave with react and would like to be able to show a numeric keyboard on mobile. Thanks!

I think this request makes a lot of sense, will add.

Hey @nosir I was actually able to get this to work by just adding the type attribute to my cleave component like this:

<Cleave
      placeholder="Phone Number"
      name="phonenumber"
      type="tel"
      options={{
              numericOnly: true,
              delimiters: ['-', '-'],
              blocks: [3, 3, 4],
          }}
      onChange={this.handleInputChange.bind(this)}
   />

Hope this helps.

@kennycrosby, Ahh, I think I did something to transfer the rest of the props all the way down to the internal input.
Glad you pointed this out :)
I will close this, @maxdonetsk feel free to open if you have problem with passing down the type.

@kennycrosby @nosir Thanks guys, it works because of {...propsToTransfer} :) I didn't pay attention on it before.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

periabyte picture periabyte  路  7Comments

shaileshrathod128 picture shaileshrathod128  路  6Comments

qm3ster picture qm3ster  路  4Comments

wcedmisten picture wcedmisten  路  4Comments

dmason30 picture dmason30  路  5Comments