Override default validation state handing - Bootstrap 4
See original GitHub issueWhat kind of issue is this? (put ‘x’ between the square brackets)
-
Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn’t working the way you expect it to, use http://stackoverflow.com/questions/ask . Provide working code, starting from http://codepen.io/marcandre/pen/jqbzyN?editors=101. We monitor the tag
parsley.js
. -
Bug report. If you’ve found a bug, you must provide a minimal example in a CodePen, starting from http://codepen.io/marcandre/pen/jqbzyN?editors=101 .
-
Feature Request. Make sure there’s no good way to do what you want first; consider asking on http://stackoverflow.com/questions/ask first.
In Bootstrap4, you need to add the error class to both the input and its wrapping ‘.form-group’ (errorsContainer). By default in ParsleyJS you can only define one error class handler and error/ success class.
I’ve hacked this for my purposes by listening to the form:validate event and injecting the additional classes but it causes issues when destroying/ resetting a parsley form as I’m unable to cleanup the additional states nicely.
Ideally, I’d like to be able to pass my own error/ success/ reset class functions into parsley to override these:
_successClass: function _successClass() {
this._ui.validationInformationVisible = true;
this._ui.$errorClassHandler.removeClass(this.options.errorClass).addClass(this.options.successClass);
},
_errorClass: function _errorClass() {
this._ui.validationInformationVisible = true;
this._ui.$errorClassHandler.removeClass(this.options.successClass).addClass(this.options.errorClass);
},
_resetClass: function _resetClass() {
this._ui.$errorClassHandler.removeClass(this.options.successClass).removeClass(this.options.errorClass);
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top GitHub Comments
I think this can be closed (unless you want to add it for bootstrap3 or others). As of Bootstrap 4.0.0.beta1 they have simplified validation classes: https://getbootstrap.com/docs/4.0/components/forms/#validation
They now just require a state/ class on the element rather than the wrapper too.
Closing then, if someone as a clear proposal, don’t hesitate to reopen or open a new issue.