-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
how to apply cleave.js format for multiple input with one class #138
Comments
I havent tryed or tested this but maybe you have to check how many elements are by this class and loop this same function same amounts. |
I would love to know anyone have tried this as well. Funny how applying class but it only works on one element. |
+1 for this issue. Was also the first thing I tried... Anyone know how to re-use these with the same classnames? |
I ended up using
|
Yea, you need a loop as above. |
If you want to use it without jQuery, Here is how it can be done document.querySelectorAll('input').forEach(function(el) {
new Cleave(el, {...options});
}); |
Could you write a code for running an |
How to make this, please? Something like this doesn't work...
|
I am using the latest version of cleave and this is my stack trace:
For the following: on a simple table with < td class="dollar-amount" >
|
Issue Solution With Vanilla Javascriptif anyone is using vanilla javascript, I leave you a piece of code that can help you solve this issue. basically:
window.onload = function () {
var datesCollection = document.getElementsByClassName("input-date");
var dates = Array.from(datesCollection);
dates.forEach(function (date) {
new Cleave(date, {
date: true,
delimiter: '-',
datePattern: ['Y', 'm', 'd']
})
});
}; remember its important convert the collection to array |
So, a question in a title.
I have a problem,
I have some inputs in form with class 'date'
code works fine, but it works for first input (for the first got the top down with that class)
how can I use this code for multiple inputs without dublicating code applying it by selector '#elemname'
need to apply it to all by class '.date'
The text was updated successfully, but these errors were encountered: