Skip to content
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

Fix Bootstrap Validation #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix Bootstrap Validation #92

wants to merge 2 commits into from

Conversation

ryumada
Copy link

@ryumada ryumada commented Feb 10, 2023

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