I'm trying to use Pristine dynamically, so I have 2 forms on the same page, I loop them through the class and then dynamically initialise them with Pristine. But the last one always works and never the first. I think that maybe the last initilisation goes to svorascribing the previous ones.
var forms = document.getElementsByClassName('my-form');
for(let form of forms) {
var pristine = new Pristine(form);
form.addEventListener('submit', function(e) {
e.preventDefault();
// on this point works only the second one, the first one return always false,
// if I have only the first one in the page, it works
// So pristine.validate(); returns alwasys false for the first one
var valid = pristine.validate();
if(valid) {
.......
} //end-valid-if
}); //end-addEventListener
} //end-for
I'm trying to use Pristine dynamically, so I have 2 forms on the same page, I loop them through the class and then dynamically initialise them with Pristine. But the last one always works and never the first. I think that maybe the last initilisation goes to svorascribing the previous ones.