K
K
KOPC18862014-11-27 12:57:11
Angular
KOPC1886, 2014-11-27 12:57:11

How to make a field required?

Hello!
There is a mold and one input.
How can I make this input required and make the button unavailable until the required fields are filled in?
jsfiddle.net/uptnx/386

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-11-27
Protko @Fesor

Let's you read the documentation anyway...
https://docs.angularjs.org/api/ng/directive/input
https://docs.angularjs.org/api/ng/directive/form

N
Nikita Gushchin, 2014-11-27
@iNikNik

In addition to Sergei Protko's answer :
https://docs.angularjs.org/api/ng/directive/ngDisabled
example (2 required fields, 1 not) jsfiddle :

<form name="myForm" ng-submit="yourSubmitFun()">
    <input type="text" ng-model="yourModel1" required />
    <input type="text" ng-model="yourModel2" required />
    <input type="text" ng-model="yourModel3" />
    <button type="submit" ng-disabled="myForm.$invalid"> Submit form </button>
</form>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question