Questions tagged validation

Explore the latest questions and answers asked by our top developers.

I don’t get the return of cross-validation to template-driven forms

I am trying to get true to return when the passwords aren’t the same. My component this.restrict = new FormGroup({ email: new FormControl(, newPassword: new FormControl (”, [Validators.required, Validators.pattern(‘(?=D*d)(?=[^a-z]*[a-z])(?=[^A-Z]*[A-Z]).{6,30}’)]), confirmPassword: new FormControl(null, [Validators.required, Validators.minLength(6)]), }, {validators: this.pwdMatchValidator}); get newPassword() { return this.restrict.get(‘newPassword’);} get confirmPassword() { return this.restrict.get(‘confirmPassword’);} pwdMatchValidator(frm: FormGroup) { let pass = frm.get(‘newPassword’).value; let […]

By Wilmer
Categorized as angular, primeng, typescript, validation Tagged , , ,

Angular 12 regex pattern validator

I have this in my angular template <div> <label for="password">Password</label> <input class="validation form-styling" type="password" formControlName="password" placeholder="Must contain none word characters" autocomplete="new-password" required [maxLength]="20" [minLength]="8" pattern="(?=.*d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*#?&^_-]).{8,20}"/> <div class="validation" *ngIf="this.newCustomerForm.get(‘password’).invalid && (this.newCustomerForm.get(‘password’).dirty || this.newCustomerForm.get(‘password’).touched)"> <div [hidden]="!this.newCustomerForm.get(‘password’).errors.required"> Password is required </div> <div [hidden]="!this.newCustomerForm.get(‘password’).errors.maxlength"> Password must be at most 20 characters long. </div> <div [hidden]="!this.newCustomerForm.get(‘password’).errors.minlength"> Password must be at […]

By Nesan Mano
Categorized as angular, html, typescript, validation Tagged , , ,

Custom validator not working in a template driven form

I wanted to add a custom validator to a template driven form in my angular project but the ngModel does not appear to register the custom validator. Do you know what might be the problem? The validator import { Directive } from ‘@angular/core’; import { AbstractControl, FormControl, NG_VALIDATORS, Validator, ValidatorFn } from ‘@angular/forms’; function usernameExistsFactory(): […]

By Jan Botek
Categorized as angular, forms, typescript, validation Tagged , , ,

Not Validating API according to the database

This is the angular code for login validation. Everything is perfect in spring boot. But in the login form if I give the Id and password from the database. It says login successful. Even if I give wrong Id and password, it says login successful. It is not validating. Please let me know what is […]

By av7888
Categorized as angular, spring-boot, typescript, validation Tagged , , ,

Custom validation on a template based form doesn’t get triggered

As the title says: custom validation of a field on a template based form doesn’t get triggered. When I try to validate whole form by passing FormGroup to validate method, it gets triggered though. But I want to validate just one field. HTML template: <input id="number" name="number" type="text" [(ngModel)]="model.number" appInvoiceNumberUnique #number="ngModel" class="form-control" [rangeLength]="[1, 45]"> Validation […]

By 11223342124
Categorized as angular, angular7, validation Tagged , ,

Two regex validation pattern for one input – angular reactive forms [duplicate]

In my component I use a input which should take a IP adress OR hostename. There for I have two regex for validation. Since it can take IP adress OR hostname only one of both need to be valid. If I enter an input like "" or "hostname" it always return not valide but actually […]

Laravel create won’t accept value unless it’s passed from the frontend

I’m trying to create a new post. If I pass the user_id from angular, the post is created without fail. However, if I use Auth::User()-> id or even just ‘2’ for instance, I get an {user_id: ["The user id field is required."]} public function store(CommentsRequest $request) { $id = Auth::user()->id; $comment = new Comment; $comment->fill($request->all()); […]

By Thornton 91
Categorized as angular, controller, laravel, php, validation Tagged , , , ,

Italian fiscal code validation/control – Angular

Could someone tell me how to check fiscal code (at least for name and surname) in Angular? EXAMPLE –> name: Lorenzo lastname: Rossi How do I check that I have correctly entered the consonants of the name and surname in the tax code? fiscal code: RSSLRN87A14L219U. At least RSSLRN is right? Unfortunately I don’t have […]

By Sophia
Categorized as angular, controls, primeng, typescript, validation Tagged , , , ,

Angular12 Form validator is validating on load page

I already search for all community and don’t find any solution. Have a form in angular inside of stepper. The problem is when page is load, the form is validating on start, making the input in red color, like this: Image Form How can i prevent this? I already try with markAsPristine and others, but, […]

By Javex
Categorized as angular, forms, validation Tagged , ,

i get an error in form validations. i can access to errors.minlength in console, but can’t do it in the template

i want that "name is too short" to be visible when last_name.errors.minlength is true. but i get an error: Property ‘minlength’ comes from an index signature, so it must be accessed with [‘minlength’]. <div> <label for="lastname">Last Name</label> <input required #last_name="ngModel" minlength="4" maxlength="10" type="text" name="lastName" ngModel> <div [ngClass]="{visible: last_name.touched && last_name.invalid}" class="message"> <div *ngIf="last_name.errors.minlength">name is too […]

By vaxo0012
Categorized as angular, html, validation Tagged , ,
1 26

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us