Pristine icon indicating copy to clipboard operation
Pristine copied to clipboard

Fix Bootstrap Validation

Open ryumada opened this issue 2 years ago • 0 comments

Based on this issue https://github.com/sha256/Pristine/issues/42, I propose this fix.

I've added some if statements to look for if self.config.classTo is the same as self.config.errorTextParent.

...
if (self.config.classTo === self.config.errorTextParent)
...

The main focus is on these lines:

if (self.config.classTo === self.config.errorTextParent) {
    errorClassElement = findAncestor(field.input, self.config.classTo);
} else {
    errorClassElement = findAncestor(field.input, self.config.errorTextParent);
}
let errorTextParent = errorClassElement;

The codes above find errorClassElement based on the values from self.config.classTo and self.config.errorTextParent. If they have the same values, then errorClassElement will take the element from classTo. If not, then errorClassElement will take the element from errorTextParent.

Some of these changes are credited from https://github.com/sha256/Pristine/pull/43 that add or remove valid and invalid classes from input field.

Here, I've created a Bootstrap Form to test out my changes. https://ryumada.github.io/Pristine-test-bootstrap/

ryumada avatar Feb 10 '23 13:02 ryumada