在窗体中有选择框,我尝试使验证,但不工作相同的输入类型文本之前我做的。我做错了什么?AngularJS验证选择框
例如
<div class="form-group">
<label class="control-label col-sm-3">Email<sup>*</sup></label>
<div class="col-sm-6">
<div class="input-icon-right">
<i class="fa fa-envelope"></i>
<input class="form-control" placeholder="[email protected]" type="email" ng-model="patient.email" name="email" required>
<p ng-show="myForm.email.$error.required" style="color:red" ng-if="myForm.email.$touched">Add your email</p>
</div>
</div>
</div>
此代码的工作好,并显示错误消息时字段为空。
并且此代码与选择框无法正常工作,每次选择不空,但有选择 - 选择 - ,如何我可以显示错误时,没有另一个chice。
<div class="form-group">
<label class="col-sm-3 control-label">{{getWord('Gender')}}<sup>*</sup></label>
<div class="col-sm-6">
<select ui-select2 ng-model="patient.gender"
data-placeholder="Tên Cơ Sở"
ng-change="changeGender()"
style="width: 100%;" requied name="gender">
<option value="">-{{getWord('Select')}}-</option>
<option ng-repeat="item in genders" value="{{item.name}}">
{{getWord(item.name)}}
</option>
</select>
<p ng-show="myForm.gender.$error.required" style="color:red" ng-if="myForm.gender.$touched">Please choice gender</p>
</div>
</div>
您需要的拼写错误? “
有什么不对?我需要显示错误信息,当没有选择这个选择 –