每当学生姓名不可用时,我都会尝试在表单上收到错误消息。
所以我尝试了这段代码
<form name="studentForm" novalidate
data-ng-submit="studentForm.$valid && enterStudentRecord()">
<div>Student Name :</div>
<input data-ng-model="studentName" required> <span data-ng-show="studentForm.studentName.$touched && studentForm.studentName.$invalid">The name is required.</span><br>
<div>Street :</div>
<input data-ng-model="street"><br>
<div>City :</div>
<input data-ng-model="city"><br>
<div>State :</div>
<input data-ng-model="state"><br>
<div>zipcode :</div>
<input data-ng-model="zipcode"><br> <br> <br>
<button type="submit">Add Student Record</button>
</form>
现在当我点击提交按钮而没有在学生姓名中输入任何值时,我没有收到错误消息。
请帮助!!
答案 0 :(得分:0)
您应该为输入
创建名称 <input data-ng-model="studentName" name ="studentName" required>