AngularJS validation patterns, syntax and properties. Validation of forms, controls, models using various angular validation directives.
1
vote
2answers
40 views
“Required” validation doesn't work in <select> with default value
I have a required <select> field:
<select name="service_id" class="Sitedropdown" style="width: 220px;"
ng-model="ServiceID"
ng-options="service.ServiceID as service....
0
votes
1answer
21 views
Angular Form Validation using Ng Model
Question: How can I show the validation error using only the ng-model if I cannot name the form and its elements.
I have a html form to collect credit card details. To prevent the credit card data ...
0
votes
1answer
46 views
Angular directive change ngmodel value from null to undefined breaks validation
I have created a plnkr to describe my problem: Link to plnkr
Problem description:
I have a number field, the value from which is written to the model. First I implemented this feature like the first ...
0
votes
0answers
23 views
Character counter on CKEditor with AngularJS
I have implemented CKEditor with AngularJS using https://github.com/esvit/ng-ckeditor in my project. But now, I have to add character counter on it. I have used wordcount plugin for that. I'm ...
0
votes
0answers
16 views
has-class not getting applied through ng-repeat form validation : angularjs
<div class="col-md-12" data-ng-repeat="p in ['A1','A2','A3']">
<div class="form-group col-md-6"
data-ng-class='{ "has-focus": form.model[p].hasFocus,
"has-success": form....
0
votes
1answer
20 views
$error.required message is not getting reset on reset button : AngularJs
<div class="form-group">
<input type="text" name="Name"
data-ng-model="panNumber" required>
<p data-ng-show="loginForm.Name.$error.required && (loginForm.Name.$touched ...
1
vote
1answer
137 views
Date validation in AngularJS
I cannot allow future date in my form built in angularjs
Here is my HTML:
<div ngCloak ng-app="laurelMoney" ng-controller="myCtrl">
<form name="userForm">
<div class="form-group"...
0
votes
2answers
49 views
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. ...
1
vote
2answers
44 views
Angular: force custom form validator to run on any field input
I've written a custom validator for a password field, in order to verify the following scenarios:
if user has id defined, then password is always valid (can be empty, meaning no change)
if user does ...
1
vote
2answers
41 views
angularjs form validation that has an internal form
I have a form by some input. and some time I have another form by some input into this form.
when I have not internal form, my parent form is valid, but when I have internal in original form and ...
0
votes
1answer
35 views
Angular JS Validation - How to turn off required for a single field
I'm trying to turn off the required attribute for a single input field in an Angular form on submit, if a certain condition is not met. I have tried the following:
form.ChangeCreditCard.$setValidity("...
2
votes
1answer
186 views
Angular Form Validation: $error.required set even when ng-required=false with custom input directive
I have Custom input component with validation with ngMessages,FormController and ng-required:
<div class="col-sm-9 col-xs-12">
<input
id="{{$ctrl.fieldName}}"
name="{{$ctrl....
2
votes
1answer
93 views
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 (...
3
votes
0answers
57 views
Validate dynamically created Check box and Radio buttons
I have an application in which dynamically check boxes and radio buttons get generated based on the data sent from the server. The number of check box/radio button displayed can increase up to 20 (in ...
4
votes
1answer
32 views
validate certain fields of a form depending upon type of user loged in
i have a form which contain 10 fields, if user type 1 is loged in only one field should be validated else all the fields should be validated.is it possible to validate certain fields depending upon ...
0
votes
1answer
20 views
Input validation: Validation message and ng-disabled buttons not working as expected
I have the following code which I'm trying to validate using AngularJS:
<div ng-form="transWizard" novalidate>
<div style="word-wrap:break-word; padding-top:4px; padding-left:14px">
...
0
votes
1answer
35 views
Invalidate form if disabled select option is chosen
Is there a way to invalidate a form if value="0" in my select tag is chosen? The reason I did this is to have a default select option show up before a user see's anything.
But even if a user doesn't ...
1
vote
0answers
26 views
ng-pattern not allowing the invalid data inside the input field
I am using a ng-pattern to validate input field string. I am facing a issue if incorrect string is not populating inside the input field. I have tried using putting this validation inside the ...
1
vote
1answer
82 views
How to enable AngularJS validation for button that is outside of form?
I am new to angular, I was struck to trigger a form validation with the button outside the form. I have two buttons one inside form, which works and one outside, I want the outside button to do the ...
0
votes
3answers
93 views
How to manually change the $error values for input tags - Angularjs
I am submitting a form via the angular $http and I want to give an error if the user bypassed the angularjs validation. I want to use the same error tag as if they didn't bypass the validation, ...
1
vote
2answers
151 views
AngularJS form input name validation not working in ngrepeat
name="number-{{$index+1}}" working in ng-repeat at the same time myform.number-{{$index+1}}.$invalid does not working for the form
Demo: http://plnkr.co/edit/Z3EmpHu8w2iZcZko9dJv?p=preview
var ...
0
votes
0answers
14 views
Angular: require vaildation triggered even if there is no require attribute
I created a custom form control which requires ngmodel and overrides required validator with the following code:
ngModelCtrl.$validators.required = function (modelValue) {
if (!modelValue) ...
1
vote
1answer
78 views
Issue in JQuery Validation with AngularJS
I use ruby on rails and Angular.
I follow - https://github.com/jpkleemans/angular-validate
I do following
APPLICATION.JS
//= require jquery
//= require app/jquery.validate.min.js
//= require ...
0
votes
1answer
249 views
angularjs single input filed for both email and mobile number
In the registration form i have single field for both email and mobile number but it doesn't working properly.
<form name="regForm" >
<md-input-container flex md-no-float>
<input ng-...
-1
votes
1answer
65 views
How to perform dropdown control validation with angular js validator?
I am doing angular js dropdown validation but getting problem when doing dropdown validation.
I have taken everything from this website and using this code:
https://github.com/turinggroup/angular-...
0
votes
0answers
37 views
What is the best practice for wrapping custom angular form controls?
In our app we have an autocomplete form control that is fairly customizable but I don't want to duplicate the same markup and logic throughout our app for common uses (searching for users/groups).
I ...
0
votes
0answers
95 views
uib-accordion validate radio buttons
the following code does disable button until radio buttons are checked in all the panels, but I want to validate the one only in the panel that is open. Please let me know what should be done.
<...
0
votes
0answers
20 views
angularjs ngModelController.$validators for custom validation $name property does not gets populated
On a custom directive inside postLink function I have ,
ngModelController.$validators.min = function(modelValue, viewValue) {... }
Now when I need to check if min validation is falling then I am ...
0
votes
2answers
85 views
Pass custom parametrs to $asyncValidators
I have directive which is an async validator:
// part of directive
return {
restrict: 'A',
scope: {
edit: '=',
},
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
...
0
votes
1answer
731 views
AngularJS validation using ng-messages without a form control
I store time as an integer of minutes in the database/model. However, I want to display it to the user in decimal hours (and let them edit the value using a number of buttons).
At the moment I have ...
0
votes
1answer
56 views
angularjs - evaluate Expression inside validator directive
I have a custom validation attribute directive that can get expressions, for example:
<input type="text" uiSelectRequired="isParam == true"/>
how do I evaluate this expression in my directive ...
1
vote
2answers
205 views
Required field Validation on input on image button click
The validation works correctly when I have it on the button with type submit. However, I have an image that acts like an image button for me and I want the project name to be filled before the user ...
0
votes
0answers
24 views
AngularJs Validation on indexed fields
I have to apply validation on a drop down list which has name as indexed variable.
<select name="data[$index+1]" ng-model="data[$index+1]" required>
and error message is like this:
<span ...
3
votes
1answer
345 views
Hide error labels shown with angularjs form validation after some time
I am using angularjs form validation for client side validation. I need to hide the labels which displaying with angularjs error form validation method, after 3 seconds, after message appear.
Html ...
0
votes
0answers
35 views
How to Manually set field as Invalid in Jcs autovalidation in angularjs?
Here Demo
Hi All,
I am using jcs validation in my project.Am doing some business level validation.so what I exactly need is I want to Manually set field as invalid based on condition inside ...
0
votes
1answer
39 views
how to validate form in email in AngularJS ?
I'm sending email using NodeJS with html/angularjs template.
There is a form, i'm sending in email. AngularJS validations are not working in email. How would I do validation?
0
votes
0answers
35 views
custom validation in angularjs forms
While working with forms in Angularjs I need to add the validation rules based on some conditions. Lets say based on a ng-model value of one attribute I need to decide if the text box is mandatory or ...
0
votes
0answers
49 views
Validating form in Angularjs with optional conditions
I have a select box in which I have two options Enable and Disable. There are two datepicker objects, one for enable time and another for disable.
If I select the Enable from the dropdown, Enable ...
2
votes
2answers
493 views
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 ...
0
votes
0answers
79 views
angularjs form validation for file input
I am using Angularjs form validation. I have a textfield and file upload filed. Currently I have handled the validation for either one of them should be present. But there are few additional rules ...
1
vote
1answer
445 views
AngularJS form remains $dirty setting every input $pristine manually
I have a HTML form[name="mainForm"] with many inputs.
When I modify an input the $scope.mainForm.$dirty becomes true (and that's right) but when I setPristine() a field I have previously modified ($...
0
votes
1answer
292 views
AngularJS trigger field validation after form loads
I have set of data fields.
They look like this:
// Read-Only
<div class="field-group" ng-if="feature.edit == false">
<div class="label" ng-class="{'feature-required': field.Validations....
0
votes
4answers
457 views
Text Input allow only Integer input in angularjs
I want to set the html input[number] <input type="number" /> to allow only integer input (not float).
Basically, the html input[number] allow '.' to be entered for float input and I don't want ...
2
votes
1answer
423 views
Validation on fields using index position
I have a couple of fields that I would like to replicate dynamically. I'm using ng-reapt which is doing the job. However, the validation messages are not working. Here's what I've got:
<html ng-...
0
votes
0answers
51 views
validation with dynamic names in AngularJS
This question was asked at least two times before Question 1 Question 2 but I thing that the answer was not complete many people use static name with ng-repeat, it's a possible solution but in my case ...
2
votes
1answer
276 views
Prevent async unique validator to validate same value only when editing?
I've got an AngularJS form that has a custom validator to check with the server backend whether the input value is unique or not. The unique validation is done by the mob-async-validate-unique ...
0
votes
1answer
104 views
validate dynamic form before submitting angular
I'm dynamically creating forms with ng-repeat and they have some validation attributes (simplified version):
<div class="row" ng-repeat="defect in model.defects">
<form name="form_{{...
2
votes
2answers
254 views
conditional styling on Form Validation AngularJs
<label class="item item-input margin5px">
<input type="email" name="email" class="form-control" placeholder="Email" ng-model="user.email" ng-minlength=5 ng-maxlength=100 required>
</...
2
votes
1answer
1k views
AngularJS Form Validation: $valid Always True
I'm having trouble with AngularJS form validation. Below is a simple two-field form with the only requirements being that data for each field is required, one of which is of "email" type.
The trouble ...
0
votes
1answer
116 views
Is ng-pattern possible on contenteditable elements?
Can't seem to find any info on this. Is it possible to use ng-pattern on a contenteditable div? When I try it doesn't work:
<div contenteditable="true" ng-model="x.number" ng-pattern='/^(\d)+$/'&...