question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Override default validation state handing - Bootstrap 4

See original GitHub issue

What kind of issue is this? (put ‘x’ between the square brackets)

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:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
fran-worleycommented, Aug 29, 2017

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.

0reactions
marcandrecommented, Sep 14, 2017

Closing then, if someone as a clear proposal, don’t hesitate to reopen or open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation · Bootstrap v5.0
Provide valuable, actionable feedback to your users with HTML5 form validation, via browser default behaviors or custom styles and JavaScript.
Read more >
Mark error in form using Bootstrap - Stack Overflow
Generally showing the error near where the error occurs is best. i.e. if someone has an error with entering their email, you highlight...
Read more >
How to Validate Forms with Bootstrap 5 - Designmodo
While Bootstrap 5 forms automatically receive the correct formatting via given classes, when it comes to form validation you need to set up ......
Read more >
How to implement Bootstrap (V5) Validation, Custom Error ...
Bootstrap 5 Crash Course · Angular 13 Bootstrap 4 Reactive Forms Validation Example to Validate Input Fields With Alert Message · How To...
Read more >
Client-side form validation - Learn web development | MDN
The simplest HTML validation feature is the required attribute. To make an input mandatory, add this attribute to the element. When this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found