if ($scope.form.$invalid) {
angular.forEach($scope.form.$error, function (field) {
angular.forEach(field, function(errorField){
errorField.$setTouched();
})
});
alert("Form is invalid.");
}
plunker:
http://plnkr.co/edit/XmvoTkIQ0yvFukrVSz11