Questions tagged [angularjs-validation]

AngularJS validation patterns, syntax and properties. Validation of forms, controls, models using various angular validation directives.

145 questions
61
votes
1 answer

AngularJS Dropdown required validation

Following is my code snippet. I want to validate my dropdown using angular. * to allow only integer input (not float). Basically, the html input[number] allow '.' to be entered for float input and I don't want that. Is there a quick way to accomplish it in…
Cheetah Felidae
  • 999
  • 2
  • 7
  • 14
9
votes
4 answers

AngularJS 'controller as' and form.$valid

I want to check if a form is valid inside an angular controller. This seems straightforward when using $scope, but I can't get it to work with the 'controller as' syntax. When I attempt to access form.$valid I get the error message "Cannot read…
ChaoticNadirs
  • 2,280
  • 2
  • 20
  • 27
8
votes
1 answer

How can i count the number of errors on Form?

FIDDLE How can i count the number of errors made on form ? HTML
Sorry but 3 errors have been made.
7
votes
3 answers

How to use the last valid modelValue if a model becomes invalid?

I'm working on an application that saves changes automatically when the user changes something, for example the value of an input field. I have written a autosave directive that is added to all form fields that should trigger save events…
Tim Büthe
  • 62,884
  • 17
  • 92
  • 129
6
votes
1 answer

Override AngularJS Default Email Validator

I want to override email validator of AngularJS. I want it to use my custom string, to validate email address. The code I found in their documentation is like this: JS: var app = angular.module('registrationApp', []); …
5
votes
2 answers

Angular - Requiring ngModel and using it in controller of custom directive, not link function

Can anybody tell me if it's possible to require and use ngModel inside the controller of a custom Angular directive. I'm trying to stay away from the link function. I see most examples use the link function but I'm thinking there must be some way to…
5
votes
1 answer

Why does an invalid form is valid at first and right after turns out invalid?

In order to simplify things I made up a sample form to describe my question:
And also a controller: angular.module('sample', []).controller('MainController',…
Carlos
  • 4,949
  • 2
  • 20
  • 37
4
votes
1 answer

Date validation in AngularJS

I cannot allow future date in my form built in angularjs Here is my HTML:
Lakshman Pilaka
  • 1,803
  • 2
  • 24
  • 48
4
votes
2 answers

Cannot read property '$valid' of undefined if form is inside a div with ng-if condition

I have a form inside a div with ng-if condition. Initially form is closed. On click a button, form is displayed. But on submitting form, I'm getting Cannot read property '$valid' of undefined error. If I change ng-if into ng-show, it works perfect.…
Akshay Vaghasiya
  • 1,597
  • 9
  • 36
  • 60
4
votes
1 answer

AngularJS form validation ngMessages not working with multi-step form

I am using AngularJS 1.5, ui-router for state management and ngMessages for validation and ngMaterial for UI. I have one main view contained in myformView.html and I load inside it two states (firstPartView.html and secondPartView.html). I followed…
1
2 3
9 10