Reputation: 3678
I have one
input field in which user can enter email
as well as 10 digit phone number
if any of this condition is fulfill i want to enable continue
button . I am able to enable
button when user type email
but I fail to enable the button when user type 10 digit mobile number
here is my code https://stackblitz.com/edit/angular-p5knn6?file=src%2Fapp%2Flogin-component%2Flogin-component.component.html
<div class="login_div">
<form #loginForm="ngForm">
<input type="text" name="email"
autocomplete="off"
placeholder="Enter the Email or Number"
[(ngModel)]="userenterValue"
required
pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$">
<input type="submit" value="Continue"
class="btn"
[class.disbled]="!loginForm.valid"
[disabled]="!loginForm.valid">
</form>
</div>
Upvotes: 2
Views: 68
Reputation: 12960
Just use the pattern like this:
pattern="^(\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+)$|^(\d{10})$"
Upvotes: 1