lundi 1 juillet 2019

Conditional pattern on input text in angularjs

I need to validate input type only in some cases with regex pattern. But when that fields is hidden , whole form isn't valid so I can't proceed. Is there a way that I can make pattern conditional

<input type="text" class="form-control" name="FileName" id="FileName" ng-model="FileName" ng-required="fileModalMode=='Rename' || fileModalMode=='Create'" pattern="^(\w+\.?)*\w+$">

So something like

<input type="text" class="form-control" name="FileName" id="FileName" ng-model="FileName" ng-required="fileModalMode=='Rename' || fileModalMode=='Create'" ng-pattern="fileModalMode=='Rename' || fileModalMode=='Create' ? '^(\w+\.?)*\w+$'">

Aucun commentaire:

Enregistrer un commentaire