javascript - AngularJS error handler is not working for radio button coupled with input -


i'm trying add radio button 2 field

all , number(this input field) (pls refer image attached) in i'm trying add error handler input field. have patter numbers "/^[0-9]{1,5}$/" (from 1 5) , if there mismatch in pattern want display error.

<div id="_work">    <md-input-container class="md-input-has-value">       <label>work funnnnn</label>          <md-radio-group layout="row" ng-model="data.group" ng-change='changecolor(data.group)'>              <md-radio-button value="all color" class="md-primary"> </md-radio-button>              <md-radio-button value="number" class="md-primary"><left empty></md-radio-button>          </md-radio-group>          <md-input-container md-no-float style="float: right; margin: 0px;">             <input name="num" ng-model="number" placeholder="5" type="text" ng-pattern="/^[0-9]{1,5}$/" class="numberrr" disabled>             <div ng-messages="num.$error" role="alert">                 <div ng-message="pattern">looks it's not number?</div>             </div>          </md-input-container>    </md-input-container> </div> 

radio button link (image)

now issue dont know why i'm not able error msg, when enter words or numbers more 5 digits. can pls i'm making mistake.

see there no error message displayed (image)

the format of regular expression off. when string passed ng-pattern, automatically wrapped in ^ , $ (see documentation), don't need these characters. don't need forward slashes @ beginning , end, need wrap regular expression in string. finally, if you're trying match numbers 1 through 5, can simplify ng-pattern following:

ng-pattern="'[1-5]'" 

however, if want match number of digits 1 5, you'll have use 1 of following:

// 0 or more digits, 1-5 ng-pattern="'[1-5]*'"  // 1 or more digits, 1-5 ng-pattern="'[1-5]+'" 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -