vendredi 27 février 2015

ng pattern for allowing only '-' in input text box

Is there any pattern that will allow only '-' in the input text box and deny entering other special characters like @, #, $ etc.I tried with the pattern ng-pattern="/^[a-zA-Z0-9]*$/" which will deny all special characters from being entered in the field.



<form name="myForm">
<input type="text" ng-pattern="/^[a-zA-Z0-9]*$/" ng-model="name" name="name">
</form>
<span class="error pop_up" ng-show="myForm.name.$error.pattern">Special Characters are not allowed</span>

Aucun commentaire:

Enregistrer un commentaire