Forked from guillefd/form-validation-pattern.component.ts
Created
April 22, 2020 13:26
-
-
Save Villanuevand/c30253371316b9897320dd7afabda40f to your computer and use it in GitHub Desktop.
Angular Form Validator Pattern: only letters and numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | |
@Component({ | |
selector: 'form', | |
templateUrl: './form.component.html', | |
styleUrls: ['./form.component.scss'] | |
}) | |
export class Form { | |
form: FormGroup; | |
constructor(private fb: FormBuilder) { | |
this.form = this.fb.group({ | |
title: ['', [Validators.pattern('^[A-Za-z0-9ñÑáéíóúÁÉÍÓÚ ]+$')] | |
], | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment