I am new in angular-js. I am developing my app with angular-kendo. I followed
- http://kendo-labs.github.io/angular-kendo/#/Validator
- http://www.telerik.com/forums/angular-kendo-validator.
Before implement the in my real project I implement it in my text project. Look at my view:
<form role="form" name="formTimeLine" kendo-validator="validator"
k-options="myValidatorOptions">
<p>{{Welcome}}</p>
<span class="label required">Name:</span>
<input type="remarks" name="remarks" class="k-textbox"
ng-model="fiscalYear.Remarks" data-test="Please write sabbir."/><br>
<span data-for='remarks' class='k-invalid-msg'></span>
<button ng-click="Save()">Save</button>
</form>
My validation rules in controller is:
$scope.myValidatorOptions = {
rules: {
test: function (input) {
if (input.is("[name=remarks]")) {
return input.val() == "Sabbir"
} else {
return true;
}
}
},
messages: {
test: "Your UserName must be Sabbir"
}
};
My save function is as follows:
$scope.Save = function () {
//$scope.formTimeLine.$valid
if ($scope.validator.validate()) {
alert("Saved");
}
else {
alert("Error");
}
};
How can I wire up a rule with kendo-validator so that remote validation will be called and validate? It is said to use custom directive and ctrl.$setValidity('unique', false);
but calling $scope.validator.validate()
return true.