Home > other >  angular form pattern validaton for one word or HH:mm
angular form pattern validaton for one word or HH:mm

Time:03-15

i try to set a pattern for HH:mm

if his shop is closed he should only able to entry "closed" or the hours if opened.

ngModel pattern="[0-9][0-9]:[0-5][0-9] && [closed]"

but this doesnt work for me.

CodePudding user response:

Write the pattern as pattern="^[0-9][0-9]:[0-5][0-9]$|^closed$"

or

pattern="^[0-9]{2}:[0-5][0-9]$|^closed$"

CodePudding user response:

ngModel pattern="^[1-2][0-9]:[0-5][0-9]$" is your pattern validation. && [closed] is something else. Please provide more context so we can help in the next steps

  • Related