primeng icon indicating copy to clipboard operation
primeng copied to clipboard

p-inputMask always decorated as valid even if mask is not complete

Open ghost opened this issue 9 years ago • 18 comments

There is no guarantee in receiving a response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeNG PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior

The p-inputmask component is always marked as valid even the input does not match the mask pattern.

<p-inputmask styleclass="form-control" ng-reflect-required="false" ng-reflect-mask="99:99:99:99" ng-reflect-slot-char="dd:hh:mm:ss" ng-reflect-auto-clear="false" ng-reflect-input-id="meter_cycle" ng-reflect-style-class="form-control" ng-reflect-disabled="false" ng-reflect-unmask="false" ng-reflect-name="meter_cycle" ng-reflect-is-disabled="false" class="ng-valid ui-inputwrapper-filled ng-touched ng-dirty" ng-reflect-model="01:hh:mm:ss"> <input pinputtext="" class="form-control ui-inputtext ui-corner-all ui-state-default ui-widget ui-state-filled" ng-reflect-ng-class="form-control" id="meter_cycle" type="text" name="meter_cycle"> </p-inputmask>

Expected behavior

Decorate component with ng-valid if mask is not complete.

  • Angular version: 4.1.0
  • PrimeNG version: 4.1.3

ghost avatar Aug 28 '17 15:08 ghost

We'll reopen if more users demand it.

cagataycivici avatar Oct 20 '17 08:10 cagataycivici

Why do you close it? The sense of an input mask is to prevent incorrect user inputs. This also includes checking the mask being completed. I understand completeness must not be mandatory (e.g. license tags can be different: "A-BB1234" vs. "A-BB12").

BUT, there are clear uses cases where completeness is crucial like credit card numbers or the IBAN. A good solution would be to add an @Input to make completeness check controllable.

ghost avatar Oct 24 '17 11:10 ghost

I have the same problem. The input is always marked as valid. You have to reopen this issue...

pablobello92 avatar Mar 21 '18 14:03 pablobello92

I have to agree here that you should be able to mark these fields as invalid. It kind of breaks the uniform behaviour of invalid field behaviour. If someone is submitting my form they have no idea it's because of the mask isn't complete because it still shows as valid visibly.

gspeach avatar Apr 04 '18 19:04 gspeach

Still having the same problem , at the first time the p-inputMask work as expected I can see the state is invalid but after I enter any value of clear existing value the state still valid

PrimeNG version: 5.2.4

malbarmavi avatar Apr 25 '18 13:04 malbarmavi

Any solution? I think they can reopen right? @cagataycivici

jsilveira2 avatar Sep 06 '18 12:09 jsilveira2

Reopen this. It's still a bug and it makes your inputMask element unusable. @cagataycivici

madvlad avatar Nov 29 '18 14:11 madvlad

Fix this issue.

hemendraub avatar Dec 25 '18 07:12 hemendraub

Reopen this issue. @cagataycivici

madvlad avatar Dec 27 '18 16:12 madvlad

I have a input mask which is allow only numeric 999.99 pattern. but, user if enter only 12 then tab out which clearing all the cell value. But, the expected behaviour resut is 12.00. Is there any way to implement. Can you help me on this. ?

palmani avatar Jan 25 '19 10:01 palmani

I can't use this control in this state

hepple avatar May 30 '19 09:05 hepple

What the current status of this issue?

talipovdaniyar avatar Jul 31 '19 11:07 talipovdaniyar

I found an interim solution via scss, I am using it, but I think it would be interesting for primeng to work for this validation to work on its own.

But for those who need an interim solution you can use this:

p-inputMask.ng-invalid.ng-touched {
    input {
        border: 1px solid #e17576;
    }
}

p-inputMask.ng-valid.ng-touched {
    input {
        border: 1px solid green;
    }
}

This solution only works if you set validations in your FormGroup...

jsilveira2 avatar Jul 31 '19 12:07 jsilveira2

I am still getting this Issue. If we set a formControl to the p-inputMask element. It is shown as valid even if the input is not complete.

midhunadarvin avatar Sep 27 '19 10:09 midhunadarvin

I am getting this problem also. Please fix.

michaelakin avatar Dec 17 '19 22:12 michaelakin

Still not working, primeng ver. 9.1.3. Please fix.

michas84 avatar Nov 18 '20 15:11 michas84

this is still not working! Primeng ver 15.2. Please reopen this issue

adeelbhaloo-tag avatar Mar 10 '23 21:03 adeelbhaloo-tag

This issue is still relevant in 2025, this is just ridiculous at this point.

Reshaw1 avatar Jan 19 '25 07:01 Reshaw1