Here I have a text box. In that field There is a validation that need to allow only numeric,alphabets and spanish characters. For that I found a function in javascript. That function is in ng-keypress, I want to change it to ng-change. If I change, The function is not firing.

How to change the function to ng-change.

**JSP code:-**

```
<input type="text" ng-model="name" ng-keypress="getPatternForAlphebet($event,$index)">

```

**script code:-**

```
 $scope.getPatternForAlphebet = function(event,rowIndex){   
        var key = key || event.which;
        if($scope.documentTypeNumber==1 || $scope.documentTypeNumber ==2){
            if ((key > 64 && key < 91)|| (key > 159 && key < 166) || (key > 96 && key < 123) || (key == 165) ||(key == 32)
                    || (key == 164) || (key == 130) || (key == 181) || (key == 144) || (key == 214) ||
                    (key == 224) ||(key == 233) || (key == 8) || (key == 241) || (key == 209)) {
            }else{
                event.preventDefault();
            }
        }else if($scope.documentTypeNumber==6){
            if ((key > 64 && key < 91)|| (key > 159 && key < 166) || (key > 96 && key < 123) || (key == 165) ||(key == 32) ||
                    (key == 59) || (key == 164) || (key == 58) || (key == 46) || (key == 44) || (key == 38) ||
                    (key == 34) || (key == 130) || (key == 181) || (key == 144) || (key == 214) ||
                    (key == 224) ||(key == 233) || (key == 8) || (key == 241) || (key == 209)) {
            }else{
                event.preventDefault();
            }
        }
    };

```