ngx-intl-tel-input icon indicating copy to clipboard operation
ngx-intl-tel-input copied to clipboard

Validation css class incorrect

Open pAnd0rASBG opened this issue 6 years ago • 6 comments
trafficstars

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

pAnd0rASBG avatar Apr 04 '19 09:04 pAnd0rASBG

Just noticed, that ng-invalid actually gets assigned to the parent component element, but not the input

pAnd0rASBG avatar Apr 04 '19 11:04 pAnd0rASBG

Temporary solution:

[cssClass]="phoneNumber.invalid ? 'form-control form-control-danger' : 'form-control'"

somq avatar Jul 29 '19 14:07 somq

Hi. Same issue here.

iradovanovic avatar Sep 18 '19 13:09 iradovanovic

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

vishnu-dev avatar Oct 10 '20 03:10 vishnu-dev

@vishnu-dev, @webcat12345 was not active on this repo for a very long time. I'm the only active maintainer.

I Will see what can be done at some point, but if someone can look at it, I will be glad to merge the PR.

pasevin avatar Oct 17 '20 16:10 pasevin

@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

somq avatar Oct 17 '20 21:10 somq