Angular - ng-Pattern - Hours

Asked

Viewed 216 times

0

In the code below I need to make ng-Pattern receive 1 or two numbers, and the format is in hours, that is, minimum node 0 or 01 and maximum 24.

<input type="text" step="any" value="" ng-model="" min="0" max="24" ng-pattern="/^([0-2]{1}[0-9]{1}$/">

1 answer

2


You can use this Pattern:

/^([0-1]?[0-9]|2[0-3])$/

Explanation:

^  "deve iniciar por"  
(  "início de um grupo"  
[0-1]?[0-9]  "zero ou um, seguido por zero a nove"  
|  "ou"  
2[0-3]  "iniciado por dois, seguido de zero a três, ou um número entre 20 e 23"
)   "fim do grupo"  
$   "fim"  
  • Tks... Ricardo!! I could understand very well.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.