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

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -