输入域的电子邮件或手机号码,如果用户输入电子邮件ID,需要显示电子邮件图标,手机号码显示国家代码
表单验证手机号码验证显示跨度+91,电子邮件ID验证显示图标,但这不是工作..如何更改图标取决于移动没有,电子邮件标识
<ion-item [class.error]="!mobilenumber.valid && mobilenumber.touched" class="tog_input animated fadeInLeft delay">
<span item-left *ngIf="mobIcon == true" class="countryCode">+91</span>
<ion-icon name="ios-person" *ngIf="emailIcon == true" item-left color="light" class="PreLoginIcon" ></ion-icon>
<ion-label id="output" class="labels" stacked floating> enter email/ mobile no</ion-label>
<ion-input type="text" [(ngModel)]=" LoginObj.mobilenumber" maxlength="45" formControlName="mobilenumber" ></ion-input>
</ion-item>
constructor() {
this.registerForm = formBuilder.group({
'mobilenumber': ['', Validators.compose([Validators.required, Validators.minLength(5), this.MailorNumber])],
'Password': ['', Validators.compose([Validators.required, Validators.minLength(2)])]
});
this.mobilenumber = this.registerForm.controls['mobilenumber'];
this.Password = this.registerForm.controls['Password'];
}
MailorNumber(control: FormControl): { [s: string]: boolean } {
var email = /^(([^<>()\[\]\.,;:\[email protected]\"]+(\.[^<>()\[\]\.,;:\[email protected]\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\[email protected]\"]+\.)+[^<>()[\]\.,;:\[email protected]\"]{2,})$/i;
var mob = /(^([1-9]{1})([0-9]{9})$)/;
if ((control.value != '')) {
return { MailorNumber: true };
}
else if (!(control.value.match(mob))){
this.mobIcon= true;
return { MailorNumber: true };
}
else if(!(control.value.match(email))){
this.emailIcon= true;
return { MailorNumber: true };
}}
请指出您面临的问题以及您尝试解决的问题。否则,它听起来像“为我完成这项任务”。 –
表单验证手机号码验证显示范围+91,电子邮件Id验证显示图标,但这不工作... – sridharan