Skip to content

Support multiple forms in the same page #100

Description

@Francesco-M

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions