How can create validation for single control's value required from multiple control in angularjs(1.*.*)

64 Views Asked by At

i.e, I have four text boxes if I enter a value in any text box out of all text box, it should be allowed to submit otherwise throw an error,"Value is Required",

It is possible using angularjs directive.

1

There are 1 best solutions below

1
leo On

You can check out the angularjs documentation here: https://docs.angularjs.org/api/ng/directive/input

For example, if you want to validate text boxes, you can have something like

<form name="validationform" ng-submit="submit()">
    <input type="text" name="value1" ng-model="textinputvalue" ng-required>
    <input type="submit" id="submit" value="Submit" />
</form>

(and similarly for the other input boxes)

If you are looking to set a custom validation, there is a really good answer here that you can look at: How to add custom validation to an AngularJS form?