how to allow only alphabets in input box with angular js

Viewed 20700

I have a input box with angular js validation.. The code is

    <div class="col-sm-12">
        <input type="text" name="drug_name" class="form-control" placeholder="Drug name" ng-pattern="/[aA-zZ\s]$/" ng-model="vmp.medication.drug_name" maxlength="150" typeahead="drugn as drugn.drugName for drugn in vmp.drugList | filter:$viewValue" autocomplete="off"  required>
<span class="pull-right font-10">(Max 150 chars.)</span>
  <span ng-messages="form.drug_name.$dirty && form.drug_name.$error">
   <span ng-message="required" class="error-inner">Drug name is required.</span>
   <span ng-message="pattern" class="error-icn">Only Alphabets are allowed</span> </span>
     </div>

The above code is validating the textbox and throwing error if I enter numbers. But What I need is , It should restrict entering numbers. The user should not be able to enter numbers in the textbox at all.. Can anyone helpme to do this..

2 Answers
Related