Form Validation angular/bootstrap

Issue Here’s FIDDLE Not able to understand that why the required validation is not working ?? HTML <div ng-app=”app”> <div ng-controller=”myctrl”> <form name=”myform” class=”form form-horizontal” novalidate> <fieldset class=”fieldset” ng-show=”payment == ‘bankAccount'” class=”form-group clearfix”> <ul class=”form-group”> <li ng-class=”{ ‘has-error’: myform.routingNumber.$invalid, ‘has-success’:myform.routingNumber.$valid}”>

Continue reading

Angular simple validation not working

Issue Here is some plunker I have created. I cant understand why it is not working. Here is the JS: angular.module(‘demo’, [ ]).controller(‘MainCtrl’, function($scope) { $scope.name = “Vlad”; $scope.age = 11; $scope.sendTest = function() { console.log($scope.name.$valid); console.log($scope.age.$valid); } }); Here

Continue reading

Form change and validity in angularjs

Issue Whenever any non-readonly input in my form changes and the form is valid, I want to do certain action. Let’s say, my form looks like <form name=”form” novalidate> <input ng-model=’input.a’ required/> <input ng-model=’input.b’ required/> <input value='{{output.p | number: 2}}’

Continue reading

Angular setValidity not working when HTML is produced in a Directive

Issue I have dynamic html that i make in a directive, and it includes an input element with validation. Example HTML produced with error message: <input id=”bob” class=”personCheckbox” name=”bob” type=”checkbox” value=”bob” ng-model=”foobar” validate-foo/> <span style=”color:red” ng-show=”myForm.bob.$error.summary”>Need Summary</span> <input type=”text” name=”summary-bob”

Continue reading

Form error not displayed using $error, $invalid

Issue I’m trying to replicate an example in ng-book jsbin. Here is my plnkr app.js var app = angular.module(‘plunker’, []); app.controller(‘MainCtrl’, function($scope) { $scope.fields = [{placeholder: ‘Email’, isRequired: true}, {placeholder: ‘Password’, isRequired: true}, {placeholder: ‘Comment(Optional)’, isRequired: false}] $scope.formSubmit = function(){

Continue reading

Why name attribute required in AngullarJs validation

Issue Friends, I am new to angularjs please explain why name attribute required for angularjs validation <form name=”lform” novalidate> <input type=”text” name=”userName” ng-model=”userName” required novalidate/> <span style=”color:red” ng-show=”lform.userName.$dirty && lform.userName.$invalid”> <span ng-show=”lform.userName.$error.required”>Username is required.</span> </span> <br/> </form> If I remove

Continue reading

Dynamic form validation in angularJS not working

Issue I have created dynamic form, And adding the ng-required attributes dynamically to my controls. but now it’s not working . This is my JS : var app = angular.module(‘birthdayToDo’, []); app.controller(‘main’, function($scope){ $scope.Control={}; $scope.Attributes =[ { “Name”:”FirstName”, “Required”:true },

Continue reading

Angularjs email validation fires too quickly?

Issue I am trying to validate an email field in angularjs which looks like this: <input type=”email” ng-model=”email” class=”form-control” name=”email” ng-required=”true” placeholder=”Email Address”> <span ng-show=”loginForm.email.$touched && loginForm.email.$invalid”>A valid email is required</span> It all works as expected, but presents a horrible

Continue reading

checkbox unchecked to make form invalid

Issue trying to add form validators for the checkbox in my form, in case if it’s unchecked the form will have ng-invalid. <li class=”terms_checkbox”><input type=”checkbox” id=”checkbox_terms” name=”terms” /><label for=”checkbox_terms”></label></li> <li class=”accept”>I have read and accept the terms and conditions</li> any

Continue reading

angularjs – not able to invalidate input (Object doesn't support property or method '$setValidity')

Issue I try to do the following if ($scope.RetypePassword != $scope.resource.Password) { $scope.resource.Password.$setValidity(“missmatch”, false); } else { $scope.resource.Password.$setValidity(“missmatch”, true); } but fail with this error TypeError: Object doesn’t support property or method ‘$setValidity’ What can the reason be? resource.Password is

Continue reading

conditional styling on Form Validation AngularJs

Issue <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> </label> I have minlength, maxlength and required validation on my email field. I want to add a class ‘has-error’ or add a certain style if any

Continue reading

validate dynamic form before submitting angular

Issue 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_{{defect.id}}” novalidate> <input ng-model=”defect.name” required/> <input type=”submit” ng-click=”saveDefect(defect)”/> </form> </div> Basically what I want to do is this: $scope.saveDefect

Continue reading

AngularJS form input name validation not working in ngrepeat

Issue 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 app = angular.module(‘plunker’, []); app.controller(‘MainCtrl’, function($scope) { $scope.choices = [{no: ‘1234567890’}, {no: ‘0987654321’}]; $scope.numberAdd = function() { $scope.choices.push({‘no’:”}); }; $scope.numberRemove =

Continue reading

Angular Form Validation: $error.required set even when ng-required=false with custom input directive

Issue 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.fieldName}}” class=”form-control” type=”text” minlength=”{{$ctrl.minLength}}” maxlength=”{{$ctrl.maxLength}}” ng-required=”{{$ctrl.isRequired === ‘true’}}” ng-model=”$ctrl.value” ng-change=”$ctrl.form.$submitted = false;” > <div ng-messages=”$ctrl.form[$ctrl.fieldName].$error” ng-if=”$ctrl.form.$submitted” > <span class=”help-block” ng-message=”required”> Field is required

Continue reading

Date validation in AngularJS

Issue 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”> <input type=’date’ id=”trandate” class=”form-control” ng-model=”trandate” required ng-class=”{ ‘has-error’ : userForm.trandate.$error }” /> <p ng-show=”userForm.trandate.$error” class=”help-block”>Transaction can’t

Continue reading

Angular JS form validation in "myApp" application.

Issue I am new to AngularJS and try to implement form validation in “myApp” app. I wrote the code below. The {{result}} should output “true”/”false”. But it didn’t work. <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js”></script> <body ng-app=”myApp” ng-controller=”myCtrl”> <form name = “myForm”> <p>Input the

Continue reading

Validate phone number using angular js

Issue Want to set phone-number to 10 digits, How can I do this using Angular js. This is what I have tried: <form class=”form-horizontal” role=”form” method=”post” name=”registration” novalidate> <div class=”form-group” ng-class=”{‘has-error’: registration.phone.$error.number}”> <label for=”inputPhone” class=”col-sm-3 control-label”>Phone :</label> <div class=”col-sm-9″> <input

Continue reading

Angularjs Form validation How can i get values inside Controller

Issue This is my Html Part <form name=”userForm” ng-submit=”submitForm()” novalidate> <!– NAME –> <div class=”form-group” ng-class=”{ ‘has-error’ : userForm.name.$invalid && !userForm.name.$pristine }”> <label>Name</label> <input type=”text” name=”name” class=”form-control” ng-model=”user.name” required> <p ng-show=”userForm.name.$invalid && !userForm.name.$pristine” class=”help-block”>You name is required.</p> </div> <button type=”submit”

Continue reading

AngularJS form validation issues

Issue I am trying to do a simple form validation using angular js. But it doesnt seems to work and I am not getting what I am missing. HTML <form role=”form” class=”ng-pristine ng-valid” name=”registerForm”> <fieldset> <div class=”form-group”> <input class=”form-control” placeholder=”First

Continue reading

AngularJS Dropdown required validation

Issue Following is my code snippet. I want to validate my dropdown using angular. <td align=”left” width=”52%”> <span class=”requiredSmall”>*</span> <select class=”Sitedropdown” style=”width: 220px;” ng-model=”selectedSpecimen().serviceID” ng-options=”service.ServiceID as service.ServiceName for service in services”> <option value=”” ng-selected=”selected”>Select Service</option> </select> </td> Valid means: Valid

Continue reading

TypeError: Cannot read property '$dirty' of undefined

Issue I have an Angular form with name p24Form <div ng-form=”private2″ name=”p24Form” ng-show=”freqSelect == ‘2.4’” novalidate=”” class=”ng-pristine ng-valid”> <div class=”form-group”> <label class=”col-sm-2 control-label”> <span class=”edit” data-pk=”private_2″>WiFi name</span>: </label> <div class=”col-sm-4″> <input type=”text” class=”form-control ng-pristine ng-untouched ng-valid” name=”freq2_name” ng-model=”ssid”> <!– tooltips:

Continue reading