0

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.

R. Richards
  • 21,615
  • 9
  • 55
  • 58
  • 1
    Welcome to SO. Please read this [how to ask](https://stackoverflow.com/help/how-to-ask). Your current question will likely attract downvotes becase it shows no research effort and is too broad for q&a format. – Yury Tarabanko Apr 25 '18 at 20:57
  • You can use the `ng-required` directive to conditionally make fields required. It can get pretty messy in markup if there are a lot of fields, but you can always write a controller function to keep the logic in one place and make it more readable. Just realize that it will get called on every digest cycle (I've never had an issue, but then I've never had my conditional required fields be dependent on more than one or two other fields). – Lex Apr 25 '18 at 22:09
  • Hello, I need to create one form which contains multiple(N) control which is static.I want to add validation for that controls.Validation should be like If we touch any of one control then every control should be mandatory.and if not then no validation should be fire – Sandip Lakum May 02 '18 at 12:28

1 Answers1

0

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?

leo
  • 186
  • 1
  • 5
  • Hello, I need to create one form which contains multiple(N) control which is static.I want to add validation for that controls.Validation should be like If we touch any of one control then every control should be mandatory.and if not then no validation should be fire – Sandip Lakum May 02 '18 at 18:17