Skip to content

Fix Bootstrap Validation#92

Open
ryumada wants to merge 2 commits into
sha256:masterfrom
ryumada:master
Open

Fix Bootstrap Validation#92
ryumada wants to merge 2 commits into
sha256:masterfrom
ryumada:master

Conversation

@ryumada

@ryumada ryumada commented Feb 10, 2023

Copy link
Copy Markdown

Based on this issue #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 #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/

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

Successfully merging this pull request may close these issues.

1 participant