I have a ng-pattern on my input field ecName which allows only alpha numeric characters. Ng-pattern works fine but the problem is I am getting two error messages one the default one and one that I have used. Please let me know how can I overwrite the default error message for ng-pattern.

<div class="">
     <input type="text" class="form-control" ng-pattern="/^[a-zA-Z0-9]*$/" id="ecName" name="ecName" ng-model="vm.employeeCorrespondence.Name" ng-change="vm.txtNameOnChange()" required placeholder="Enter a Name" value="{{vm.employeeCorrespondence.Name}}" />
     <div class="help-block has-error error-msg" ng-show="documentForm.ecName.$error.pattern" gi-translate="NameMsg" b-entity="vm.translationEntity">Please enter only alpha numeric characters</div>
</div>

Output

Please ensure the entered information adheres to this pattern /^[a-zA-Z0- 9]*$/

Please enter only alpha numeric characters

I want to show only the error message which I have defined in div - Please enter only alpha numeric characters

share|improve this question
    
Create a snippet, reproducing your issue. It will be easier to see what's happening once we see you exact code. – A.J 41 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.