خرید بک لینک

Vote count: 0

I try to validate the input of restricted characters. The input field only accept alphabet, dash and underscore characters.

When I test the code below, the first character is accepted, but the second one raise a patte error.

My RegEx: /^[a-zA-Z_-]$/

HTML code:

<input ng-model="inputText" name="inputText" required md-maxlength="{{options.maxTextLength}}" md-autofocus ng-keypress="keypress($event)" ng-change="textChanged()" ng-patte='/^[a-zA-Z_-]$/'>
<div ng-messages="inputTextForm.inputText.$error">
    <div ng-message="required">Input is required.</div>
    <div ng-message="md-maxlength">Input has reached the maximum characters allowed.</div>
    <div ng-message="patte">Invalid characters.</div>
</div>

This code is in an Angular Material Dialog (v1.0.9)

asked 39 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 6 مرداد 1395 ساعت: 1:59

صفحه بندی