i just want to validate textbox in my project in such a way so that a user could not enter any value other than characters.
Hackish? way, $watch the ng-model in your controller:
<input type="text" ng-model="myText">
Controller:
$scope.$watch('myText', function() {
// put logic to strip out all non-character characters here
if ($scope.myText ... regex to look for ... ) {
// strip out the non-characters
}
})
Best way, use a $parser in a directive. I'm not going to repeat the already good answer provided by @pkozlowski.opensource, so here's the link: http://stackoverflow.com/a/14425022/215945
Don't try to use ng-change -- it will cause problems. See AngularJS - reset of $scope.value doesn't change value in template (random behavior)
Update: ng-pattern can also be used to define a regex that will limit what is allowed in the field. See also the "cookbook" page about forms.