tanansatpal / ngx-mat-intl-tel-input

MIT License
62 stars 108 forks source link

Is there any event or triger to clear input value when change country code #192

Open abhinaykm opened 7 months ago

abhinaykm commented 7 months ago

`` image

jalalbmnf commented 7 months ago

Hi, can you share code block?

abhinaykm commented 7 months ago

Dear Jalalbmnf ,

I hope this email finds you well. I have a few questions related to our phone number input field and its behavior when changing the country. Your assistance with these queries would be greatly appreciated:

Clearing Phone Number on Country Change: Is there a specific procedure or best practice to clear the phone number input when a user changes their selected country? We want to ensure a smooth transition when switching countries.

Country Code and Selection: I've noticed an issue when a user selects a country with a country code that begins with "+1," such as the United States, and then changes it to another country, for example, Canada. It seems that the country is not being selected correctly due to the shared country code. How can we address this challenge?

Setting Maximum Length for Phone Numbers: Is there a directive or method you recommend to set a maximum character length for phone numbers in our input field? We want to ensure that users provide phone numbers within a specified limit. I am sharing a shortcode with you please check...

Thank you for your time and guidance on these matters. Your insights will be invaluable in improving our user experience.

--------------------.html--------------------------------------------------

<ng-template #content let-modal> <form [formGroup]="branchForm" (ngSubmit)="submitForm()">

            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-danger bg-gradient"

(click)="closeModal()">Cancel

----------------------------.ts ------------------------- ngOnInit(): void { this.propInit(); } propInit() { this.branchForm = this.fb.group({ id: new FormControl(0), email: new FormControl('', [Validators.required, Validators.pattern(this._common.regex.email)]), phone: new FormControl('', [Validators.required]), createdBy: new FormControl(''), }) } get f(): { [key: string]: AbstractControl } { return this.branchForm.controls; }

--------------------------------------.module.ts----------------------

I have import library in module

import { MatInputModule } from @.***/material/input'; import { NgxMatIntlTelInputComponent } from 'ngx-mat-intl-tel-input';

@NgModule({ declarations: [], imports: [ CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, NgxMatIntlTelInputComponent ], exports:[ FormsModule,ReactiveFormsModule, MatInputModule,NgxMatIntlTelInputComponent ], providers: [

], }) export class SharedModule { }

------------package.json-------------------

@./animations": "^14.2.10", @./cdk": "^13.0.0", @./common": "^14.2.10", @./compiler": "^14.2.10", @./core": "^14.2.10", @./forms": "^14.2.10", @./localize": "^14.2.10", @./material": "^13.0.0", "ngx-mat-intl-tel-input": "^5.0.0",

On Sat, Nov 4, 2023 at 6:14 PM jalalbmnf @.***> wrote:

Hi, can you share code block?

— Reply to this email directly, view it on GitHub https://github.com/tanansatpal/ngx-mat-intl-tel-input/issues/192#issuecomment-1793433557, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5C4MDHYFF5NLIOBUHVYNDYCY2ENAVCNFSM6AAAAAA6XEPOQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGQZTGNJVG4 . You are receiving this because you authored the thread.Message ID: @.***>

-- ABHINAY KUMAR MISHRA

jalalbmnf commented 6 months ago

Hi @abhinaykm, I wrote my intl tel input

rbalet commented 4 months ago

Hi @abhinaykm.

Since this library isn't maintained anymore, I did enhance it in a library fork.

I've added a new resetOnChange attribute that should resolve your issue on the following version: https://github.com/rbalet/ngx-mat-input-tel/releases/tag/v17.2.0

If you wish to test it out ;) https://www.npmjs.com/package/ngx-mat-input-tel

Cheers