Home > Back-end >  Angular reactive form contain field which is localpath which allow at least two slashes in regex wha
Angular reactive form contain field which is localpath which allow at least two slashes in regex wha

Time:12-31

I have tried my reg exp but it is not working. I want this regex to have at least two slashes

<div
  
  *ngIf="dropboxForm.get('localPath')?.hasError('pattern')"
>
  <p>special characters allowed</p>
</div>

ts file

localPath: new FormControl('', [
  Validators.required,
  Validators.pattern('^[a-zA-Z ][/]{2,} $'),
]),

CodePudding user response:

What are you trying to validate? please add more information about it.

CodePudding user response:

In your .ts file, Use escape character '\' for '/' as ^[a-zA-Z ][\/]{2,} $

  • Related