html Angular_FORM_VALIDATION(Temple驱动表格)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Angular_FORM_VALIDATION(Temple驱动表格)相关的知识,希望对你有一定的参考价值。
<form novalidate #form="ngForm" (ngSubmit)="onSubmitForm(form)">
<div class="container">
<div class="form-group">
<label >Name</label>
<input type="text" class="form-control"
[(ngModel)]="user.name" name="name"
#userNameForForm = "ngModel"
minlength="5"
required >
<!--pop-up validation-->
<div *ngIf="userNameForForm.errors?.required && userNameForForm.touched" class=" alert alert-danger">
Name is required
</div>
<div *ngIf="userNameForForm.errors?.minlength && userNameForForm.touched"
class=" alert alert-danger">
Name should be at least 5 characters
</div>
</div>
<div class="form-group">
<label >Email</label>
<input type="email" class="form-control"
[(ngModel)]="user.email" name="email"
#userEmailForForm = "ngModel"
required >
<div *ngIf="userEmailForForm.errors?.required && userNameForForm.touched" class=" alert alert-danger">
Email is required
</div>
</div>
<div class="form-group">
<label >Phone</label>
<input type="number" class="form-control"
[(ngModel)]="user.phone" name="phone"
#userPhoneForForm = "ngModel"
>
<div *ngIf="userPhoneForForm.errors?.required && userPhoneForForm.touched " class=" alert alert-danger">
Phone should be at least 3 numbers
</div>
</div>
<input type="submit" value="Submit" class="btn btn-success" >
</div>
</form>
以上是关于html Angular_FORM_VALIDATION(Temple驱动表格)的主要内容,如果未能解决你的问题,请参考以下文章
html Html模板/ Html Boilerplate |标签HTML
html里怎么引用一个html的头部
html5与传统html区别
html4和html5的区别
HTML元素
head标签怎么给多个html引用