AngularJS - use input field as a fiter and as an input field at the same time -
i got page list of emails , have input field there, got 2 purposes: - filter list of friends - if no friend email found - make add friend button available send friendship request
the problem got validation on field , when i'm trying make search, system applies ng-pattern, so, if got email aa@aa.aa on list, filter find aa@aa.aa text, not aa (as without ng-pattern).
i don't want use 2 fields this, so, there workarounds?
code:
<td> <input type="text" id="email" name="email" ng-model="searchforfriend" ng-pattern="/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/" ng-minlength="3" ng-maxlength="100" required placeholder="your friend e-mail" ng-blur="focused1 = false" ng-focus="focused1 = true" /> <span ng-show="focused1 && !friendsform.email.$valid"><error><br>e-mail incorrect</error></span> <span ng-show="focused1 && friendsform.email.$error.maxlength"><error><br>e-mail long</error></span> <input type="button" id="sendrequest" value="send request" ng-click="savecontact()" ng-disabled="!friendsform.$valid && !friendsform.contactsamount.length" class="btn btn-primary"/> </td> ..... <tr ng-repeat="contact in friends|filter:searchforfriend|filter:{id_dictionary:'2'} contactsamount"> <td align="left">{{ contact.email }}</td> </tr>
based on @jbnizet comment -
<input type="text" id="email" name="email" ng-model="searchforfriend" ng-pattern="/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/" ng-minlength="3" ng-maxlength="100" required placeholder="your friend e-mail" ng-blur="focused1 = false" ng-focus="focused1 = true" ng-model-options="{allowinvalid: true}"/> <span ng-show="focused1 && !friendsform.email.$valid"><error><br>e-mail incorrect</error></span> <span ng-show="focused1 && friendsform.email.$error.maxlength"><error><br>e-mail long</error></span> <input type="text" placeholder="search friend" ng-model="searchforfriend" style = "width:99%;">
Comments
Post a Comment