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

Support multiple delimiters #37

Closed
vicentedealencar opened this issue Jul 14, 2016 · 11 comments
Closed

Support multiple delimiters #37

vicentedealencar opened this issue Jul 14, 2016 · 11 comments

Comments

@vicentedealencar
Copy link

Today there is only support for a single delimiter, so some more complex patterns can't be done.

Some examples:

  • 999.999.999-99 BR CPF (like US social security for BR people)
  • (99)99999-9999 BR phone

My proposal to fix that is add delimiters option that would take a array of delimiters, each to be used one time in the rigth order between blocks. This wouldn't add breaking changes. Maybe some validations should be applied like not allowing both delimiter and delimiters at the same time, and delimiters.length === blocks.length - 1.

The options passed to a CPF input would be

{
  blocks: [3,3,3,2], 
  delimiters: ['.', '.', '-'], 
  numericOnly: true
}
@renatoagds
Copy link

@vicentedealencar +1 to support this feature, for Brazil will be an awesome feature.

@rafaell-lycan
Copy link

That's will be great. WE haven't good libs that support brazilian formats. +1

@gibatronic
Copy link

Another way would be to supercharge the blocks option:

{
  blocks: [3, '.', 3, '.', 3, '-', 2]
}

Which would be nice for other uses as well:

{
  blocks: [3, '.', 2, '%']
}

@renatoagds
Copy link

@gibatronic I liked your idea, but this change will have a good impact in the library.

@gibatronic
Copy link

yea @renatoagds... it would be hard to avoid weird glitches. 😔

@gibatronic gibatronic mentioned this issue Jul 27, 2016
@gibatronic
Copy link

I've submitted a suggestion for an IdFormatter, if anyone could help it would be great!

@renatoagds
Copy link

Amazing @gibatronic.. I am going to look that today, maybe I could help w/ something.

@trjiang
Copy link
Collaborator

trjiang commented Jul 28, 2016

Sorry guys, I've closed the Id card formatter PR. Id card number is a specific requirement, we won't merge formatter for a relatively specific feature to the main repo.

Besides, multiple delimiters option is something we can add, @nosir is looking at that and will add soon.

Cheers.

@nosir
Copy link
Owner

nosir commented Jul 31, 2016

Release published. Please see: https://github.com/nosir/cleave.js/blob/master/doc/options.md#delimiters
Won't change blocks usage, that will confuse other users.

A demo is added to homepage: http://nosir.github.io/cleave.js/

Cheers.

@nosir nosir closed this as completed Aug 1, 2016
@vicentedealencar
Copy link
Author

Awesome, dude!

One thing, it looks like there is a missing s on the example delimiter: ['.', '.', '-'].

@nosir
Copy link
Owner

nosir commented Aug 3, 2016

Oops, will fix it at night. Good catch!

@nosir nosir added the resolved label Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants