title: How to restrict special characters and letters for input field in angular 5
body: <p>I'm trying to add an input restriction pattern in Angular 5 to an input field so users can only input the following (1234567890-.)</p>
  
  <pre><code>&lt;div class="input-group"&gt;
  &lt;input type="text" id="btn" (keyup.enter)="Submit(Car.value);" class="form-control" name="Car" #Car required placeholder="Car name" [value]="CarSearch" [pattern]="nameFormat"&gt; &lt;/div&gt;
  </code></pre>
  
  <p>And in the component:
  i declare my pattern(wrong regex pattern):</p>
  
  <pre><code>nameFormat = "[a-zA-Z\s]+$";
  </code></pre>
  
  <p>then in constructor:</p>
  
  <pre><code>this.name = new FormControl("", Validators.compose([Validators.required, Validators.pattern(this.nameFormat)]));
  </code></pre>
  
  <p>How can i achieve the correct regex pattern and restrict user input, the current solution is not working...thank you for suggestions and ideas.</p>