From looking your problem it loks like not updating your CSS class based on the ng-pattern. Not gone into detail but this plunkr might help you.
https://plnkr.co/edit/JSgH3LZHQysIO71u03yF?p=preview
var myApp = angular.module('myApp', []);
myApp.controller("MyCtrl", function ($scope) {
var tThis = this;
$scope.dataTypeList = [{
'id' : 1,
"label" : "Currency"
}, {
'id' : 2,
"label" : "Number"
}, {
'id' : 3,
"label" : "Text"
}
];
$scope.dataTypeValue;
$scope.textValue
$scope.customPattern = '';
$scope.className = "ng-invalid ng-invalid-pattern"
$scope.setCustomPattern = function () {
var dataTypeId = $scope.dataTypeValue.id;
console.log(dataTypeId + 'llsdkfalskdf');
if (dataTypeId === 1) {
$scope.customPattern = /^\d{1,10}$/;
} else if (dataTypeId === 2) {
$scope.customPattern = /^\d+$/;
} else if (dataTypeId === 3) {
$scope.customPattern = /^.*$/;
}
return $scope.customPattern
};
$scope.$watch("[dataTypeValue, textValue]", function (nw, old) {
var s = $('input[name=input]').val()
$scope.textValue = s;
var pattern = $scope.setCustomPattern()
if (pattern.test($scope.textValue)) {
$scope.className = "ng-valid ng-valid-pattern"
} else {
$scope.className = "ng-invalid ng-invalid-pattern"
}
});
});