Skip to content

Please give example of Form validation in angular #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rajnesh-rathor-auxano opened this issue May 25, 2023 · 2 comments
Open

Please give example of Form validation in angular #315

rajnesh-rathor-auxano opened this issue May 25, 2023 · 2 comments

Comments

@rajnesh-rathor-auxano
Copy link

I have tried HTML one but not able to successfully implement it in angular. could someone please

@HenryKim2022
Copy link

Me too :) never working as sampled on AdminLTE3

@rajnesh-rathor-auxano
Copy link
Author

rajnesh-rathor-auxano commented Jun 12, 2023

I have implemented it in angular

@ViewChild('stepper1', { static: false }) stepperRef!: ElementRef;
        this.stepper = new Stepper(this.stepperRef.nativeElement, {
            linear: false,
            animation: true,
        });

        const validateForm1Fields = [
            'firstName',
            'lastName',
            'gender',
            'email',
            'mobileNumber',
            'governmentId',
            'address',
            'zipCode',
            'country',
            'state',
            'city',
        ];

        this.renderer2.listen(this.stepperRef.nativeElement, 'show.bs-stepper', (event: any) => {
            if (event.detail.from === 0) {
                if (
                    !validateForm1Fields.every((x) => this.ngForm.controls[x].status === 'VALID')
                ) {
                    this.submitted = true;
                    event.preventDefault();
                } else {
                    this.completedStep1 = true;
                    this.submitted = false;
                }
            }
        });
    }
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants