Guest User

Untitled

a guest
Jun 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <md-input-container class="fill-width-input-wrap">
  2. <input mdInput placeholder="Zip Code" formControlName="zipCode" minLength="5" maxLength="7" (keypress)="allowOnlyNumbers($event)" required>
  3. <md-error *ngIf="clientInformationForm.controls['zipCode'].hasError('required')">
  4. Please enter
  5. <strong>valid zipcode</strong>
  6. </md-error>
  7. <md-error *ngIf="clientInformationForm.controls['zipCode'].hasError('minLength')">
  8. zip code
  9. <strong>minimum length is 5</strong>
  10. </md-error>
  11. </md-input-container>
  12.  
  13. <input mdInput formControlName="zipCode"
  14. minLength="5" maxLength="7"
  15. pattern="zipPattern"
  16. (keypress)="allowOnlyNumbers($event)"
  17. required>
  18. <md-error *ngIf="clientInformationForm.controls['zipCode'].hasError('pattern')">
  19. zip code must satisfy pattern
  20. </md-error>
  21. ...
  22.  
  23. const pattern = new RegExp(/^d{5}(?:d{2})?$/)
  24. '1234'.match(pattern) // null
  25. '12345'.match(pattern) // ["12345"
  26. '123456'.match(pattern) // null
  27. '1234567'.match(pattern) // ["1234567"
  28. '12345678'.match(pattern) // null
Add Comment
Please, Sign In to add comment