【发布时间】:2015-07-31 20:55:31
【问题描述】:
我正在尝试在下面的字段上添加验证,但我收到错误消息,但它仍然让我保存该字段,我不确定我错在哪里,请帮助..
到目前为止尝试过的代码...
验证.html
<form name="createProcessFormName"
name="form" role="form" class="form-horizontal"
kendo-validator="validator" k-validate-on-blur="false"
k-options="myValidatorOptions" ng-submit="validate($event) && createProcessFormName.$invalid">
<div class="col-md-7">
<div multiselect-dropdown-tree ng-model="nonPersistentProcess.geoLocations" ng-class="{'disabled': disableGeoLocations}" disable-children="true" options="treeviewOptions"></div>
<p class="status" ng-show="geoLocationRequired">*GeoLocation is required field*</p>
</div>
<button require-control-point="PROCESS_ADD"
ng-hide="editMode" class="btn btn-primary pull-right" type="button"
ng-click="validate($event)">Save</button>
验证.js
$scope.validate = function ($event) {
if(!$scope.nonPersistentProcess.geoLocations.length || $scope.nonPersistentProcess.epcfKey || $scope.nonPersistentProcess.legalEnty || $scope.nonPersistentProcess.erhKey){
if($scope.createProcessFormName.$invalid){
$scope.geoLocationRequired = true;
$event.preventDefault();
}
}
【问题讨论】:
标签: javascript html angularjs validation