Angular js. Form validation

Главная » Tutorials » JavaScript » Angular js. Form validation

In this tutorial we will consider form validation with angular. The main advantage of using angular to validate form is simplicity and fast implementation.

While making validation you need some important steps. First of all you need to add name attribute to form. After form will be available in $scope object. In fact form is instance of Form Controller. Next we must add name attribute to form input fields. After the will be available inside form object in $scope object. See image below.

Fields have got several important angular properties which use while form validation. Each of them can be true or false. See code example below.

Using these properties, we can validate our form. In our example we will check if fields are required. Approach is we will check propeties on boolean values. For example, we will add ng-disabled directive and it will act only when one of the field is not valid.

Подписаться на рассылку

Будьте в курсе - получайте последние статьи на свой email

Ваша подписка успешно оформлена

Pin It on Pinterest

Share This