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

Autofill Special Characters #27

Open
Auer111 opened this issue Dec 28, 2020 · 2 comments
Open

Autofill Special Characters #27

Auer111 opened this issue Dec 28, 2020 · 2 comments

Comments

@Auer111
Copy link

Auer111 commented Dec 28, 2020

After some testing I found some users found it unintuitive to only type numbers for masked dates. (they would try to type in the slashes). If there is some functionality I didn't understand that supports this in the docs let me know, otherwise I found this solution.

inside of handleCurrentValue
after the for loop add

if (value.length < l) { if (placeholder[value.length].match(/\W/)) { newValue += placeholder[value.length]; } }

Example: 12/25 -> 12/25/

@Auer111
Copy link
Author

Auer111 commented Dec 28, 2020

Found the solution above was a bit limiting so here is a new version with support for things like

XXABC-XXX

in handleCurrentValue
var isCharsetPresent = e.target.getAttribute('data-charset'), placeholder = isCharsetPresent || e.target.getAttribute('data-placeholder'), value = e.target.value, l = placeholder.length, newValue = '', i, j, isInt, isLetter, strippedValue, regNot = new RegExp("[^"+this.opts.mNum+this.opts.mChar+"]");

and after the for loop
if (newValue.length >= value.length) { for (i = newValue.length; i < l; i++) { if (placeholder[i].match(regNot)) { newValue += placeholder[i]; } else { break; } } }

@cepm-nate
Copy link

This helped, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants