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.

Validation css class incorrect

See original GitHub issue

Upon entering an incorrect/incomplete Phone number (e.g. just country code), .errors correctly reflects { "validatePhoneNumber": { "valid": false } } but the actual input has class=“form-control ng-valid ng-touched ng-dirty”.

Expected behavior:

“ng-valid” should be “ng-invalid”

Details:

in component: this.details = fb.group({ phone: [undefined, [Validators.required]] });

in template: <ngx-intl-tel-input [preferredCountries]="['au', 'us', 'gb', 'de']" [enablePlaceholder]="true" [enableAutoCountrySelect]="true" name="phone" id="phone" formControlName="phone"></ngx-intl-tel-input>

classes on load (empty): form-control ng-untouched ng-pristine ng-valid classes on touch (empty): form-control ng-pristine ng-valid ng-touched classes on invalid value: form-control ng-valid ng-touched ng-dirty classes on valid value: form-control ng-valid ng-touched ng-dirty

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:6

github_iconTop GitHub Comments

1reaction
somqcommented, Jul 29, 2019

Temporary solution:

[cssClass]="phoneNumber.invalid ? 'form-control form-control-danger' : 'form-control'"
0reactions
somqcommented, Oct 17, 2020

@somq Your solution doesn’t work with Bootstrap 4. @webcat12345 Please look into this issue.

@vishnu-dev Did you try to investigate the new BS4 class for validation?

Try replacing form-control-danger by was-validated

Read more comments on GitHub >

github_iconTop Results From Across the Web

invalid - CSS: Cascading Style Sheets - MDN Web Docs
The :invalid CSS pseudo-class represents any , , or other element whose contents fail to validate.
Read more >
Form validation javascript adding css error class not working
The validation function adds a CSS error class and then should show the error message, the error border and the erros symbol.
Read more >
Styling Form Inputs in CSS With :required, :optional, :valid and
We can use the :required , :optional , :valid and :invalid pseudo-classes coupled with HTML5 form validation attributes like required or ...
Read more >
AngularJS Validation CSS Classes - TutorialsTeacher
This tutorial explains built-in css classes in AngularJS for styling form fields based on its state.
Read more >
CSS :invalid Selector - W3Schools
The :invalid selector selects form elements with a value that does not validate according to the element's settings. Note: The :invalid selector only...
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