Search Posts

Category: validation

Enter a negative number in the input number field and validation with ng-pattern-restrict

I’m having problems with ng-pattern-restrict I have an input number field with ng-pattern-restrict = “^. {0,13}? $” But when I wanted to enter a negative number, I tried two ways: ng-pattern-restrict = “^ – d {0,13}? $”: This way, the negative number is good, but it does not allow you to enter positive numbers, because the character at the start must be (-) ng-pattern-restrict = “^ d {0,13} ( – d {0,13})? $”: this method […]

Angular validation works on edit forms but not on new forms“

The code below illustrates angular js validation for an Edit Employee form and a New Employee form. The edit form validation works fine, the new form does not. Please help. I checked all the tags, made sure Required is set. The newUser fields are set correctly and it will create a user if all fields are filled in. <div class=”panel panel-primary”> <div class=”panel-heading”> New Employee </div> <div class=”panel-body”> <form role=”form” novalidate angular-validator name=”addUserForm” angular-validator-submit=”Register()”> <table […]

Angular Validation > Multiple directives requesting isolated scope

I’m attempting to use multiple angular validators on a text field, but have run into the Multiple directives requesting isolated scope error. (Please read on before closing as a duplicate.) All the solutions I’ve seen so far, recommend removing the scope: {…} from the offending directives, however for my scenario, I need to evaluate variables from the controller (and $watch them for changes). I’ve tried using attrs.$observe, but I can’t work out how to get […]

Date comparison validation in angular

I have 2 dates: 1.start and 2.end format is like this. 12/4/2017 console.log(startDate); 12/20/2017 console.log(endDate); I am writing a validation to check if the end date is bigger than start date throw error. this is what i have tried: var startDate = new Date(this.formB[‘startDateVal’]).toLocaleDateString(); var endDate=new Date(this.formB[‘dueDateVal’]).toLocaleDateString(); this is my condition: if(endDate<startDate){ this.bucketMsgClass=’fielderror’; this.bucketSuccessMsg = ‘End Date is must lower than Start Date.’; } where am i doing wrong.? Source: AngularJS

how to trigger a validation of child component from parent component OnSubmit Angular 4?

I Have forms like this, in parent i am including multiple child components each child component is formgroup. now i need to check all this child forms validation on parent form when user click OnSubmit. How should i trigger child form validations from parent on submit. I have used FormBuilder in each childcomponent. I am able to do validation when user click on child fields but if user doesn’t enter anything or touched anything and […]

Looking for help a regex that prevents special characters except ‘, space and – in the string but disallows them at the start

I have been scouring the internet for answers to this regex question and I have come quite close to getting it but I think I am missing one or two more groups to prevent the special characters at the start and end of the string. It is for use in angularJS and the full specification is a string of letters that cannot be longer than 20 characters, will only allow -,’ and space as the […]

AngularJs input field validation

I have an input field on my HTML page and I want to put some validations on it. Limit the number of characters that the field can hold (say 6 maximum). The field can only contain numeric characters. the field is disabled if it does not contain 6 Zeros (000000). The field should be editable if it contains 6 Zeros (000000). <input type=”text” ng-model=”testfield” placeholder=”XXXXXX” ng-maxlength=”6″ ng-disabled=”testfield !=’000000′” ng-required=”testfield ==’000000′” ng-pattern=”/^[0-9]{6}$/”> Source: AngularJS

Not validating new controls after submitting form in angularjs

We have a form which we are submitting on save button. There are some validation firing on save. We are submitting form using $scope.isSubmitted= true and $ on $scope.isSubmitted for error highlighting After submitting and validating the form, if there is any new controls add to form on the basis of ng-if condition the new controls are also validated. So my question is how to prevent new controls which being added after submitting the form […]

Masking input AngularJS

I need to create mask for input field where user can input symbols only like in template: “01ABC2345-67-89” – two digits, then three chars, then four digits, then “-“(or if he input digit, “-” add automatically), then two digits, “-” and again two digits. There is my code – my mask filter only numbers. Ho to create regexp for my objective? html: <html ng-app=”app”> <head> <meta charset=”UTF-8″> <title>serialNumber mask</title> <script src=””></script> <script type=”text/javascript” src=”main.js”></script> </head> […]

ngMessage/ngMessages do not work , AngularJS

I’m trying to validate a phone number using the ngMessages and ngMessage directives, but I am facing two problems: The “Invalid Input” message is shown only after the pattern’s expression is met and the user continued typing. The “required” message is not shown when the input is empty. I want the “Invalid Input” to be shown as soon as the user starts typing, and not only after the pattern is met. I don’t understand what […]

Next Page »