【发布时间】:2017-07-28 05:00:26
【问题描述】:
当字段为空时,我试图禁用提交按钮。但它不工作。不知道为什么它不起作用。看了很多博客,但不知道是什么问题。
<form name="createForm">
<div class="form-group col-md-6">
<label for="createName">Student</label>
<select class="form-control" name="student" id="createName" ng-
model="createStudent.studentId" ng-options="item.name for item in
allStudent" required>
<option value="" selected disabled>Select</option>
</select>
</div>
<div class="form-group col-md-6">
<label for="createClass">Class</label>
<select class="form-control" name="class" id="createClass" ng-
model="createStudent.classId" ng-options="item.number for item in
allClass" required>
<option value="" selected disabled>Select</option>
</select>
</div>
</div>
<div class="form-group col-md-6 text-md-center">
<label for="createCategory">Type of Category</label>
<select class="form-control" name="category" id="createCategory"
ng-model="createStudent.type" ng-options="item.category_type for
item in allcategoriestypes" required>
<option value="" selected disabled>Select</option>
</select>
</div>
</div>
<div class="row align-items-end justify-content-center">
<div class="form-group col-md-6 text-md-center">
<label for="createTeacherName">Teacher Name</label>
<input type="text" class="form-control" name="teacher"
id="createTeacherName" ng-model="createStudent.name"
placeholder="Enter Teacher Name" required>
</div>
</div>
</div>
<div class="text-center pt-1">
<button type="submit" class="btn btn-info px-5" ng-
click="create(createStudent)" ng-
disabled="createForm.$invalid">Save</button>
</div>
</form>
【问题讨论】:
-
请在下面我的回答中检查 plunker
-
我检查了,在我的项目中它不起作用。
-
有什么问题?
-
我正在使用 ng-include 加载表单。我删除了 ng-include 并直接加载了表单,现在它可以工作了。
-
哦,好的。但我想我的 plunker 正在工作?尽管我的回答有效,但您不接受我的回答。
标签: angularjs forms validation