javascript - Form validation angular -


i have couple of fields in form & want enable submit button if of them filled, how can this? if put required both or of them won't work want.

<input type="text" name="phone"> <span ng-show="form.addcontactform.phone.$touched && form.addcontactform.phone.$error.required">phone number or email required</span> <input type="text" name="email"> <span ng-show="form.addcontactform.email.$touched && form.addcontactform.email.$error.required">phone number or email required</span> <button type="submit" ng-disabled="form.addcontactform.$invalid || form.addcontactform.$submitted">submit</button> 

if phone or email entered other message should hide

you add conditions in

<input type="text" name="phone" ng-model="ctrl.phone"> <span ng-show="(form.addcontactform.phone.$touched || form.addcontactform.email.$touched) && !ctrl.phone && !ctrl.email">phone number or email required</span>  <input type="text" name="email" ng-model="ctrl.email"> <span ng-show="(form.addcontactform.phone.$touched || form.addcontactform.email.$touched) && !ctrl.phone && !ctrl.email">phone number or email required</span>  <button type="submit" ng-disabled="(!ctrl.phone && !ctrl.email) || form.addcontactform.$invalid || form.addcontactform.$submitted">submit</button> 

edit: add error message , condition


Comments

Popular posts from this blog

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -