jackocnr / intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers. React and Vue components also included.
https://intl-tel-input.com
MIT License
7.64k stars 1.95k forks source link

Hidden fields should not be added if existing already #1843

Open larsblumberg opened 2 weeks ago

larsblumberg commented 2 weeks ago

Plugin version

v24.6.0

Steps to reproduce

  1. set hiddenInput: () => ({ phone: "phone_full", country: "phone_country" })`
  2. provide these hidden inputs yourself in the form (there are advantages for certain scripting like referencing these before the library creates them dynamically)

Expected behaviour

Actual behaviour

image

Initialisation options

  intlTelInput(input, {
    hiddenInput: () => ({ phone: "phone_full", country: "phone_country" }),
    loadUtilsOnInit: () => import("intl-tel-input/utils"),
  });
jackocnr commented 2 weeks ago

I'm onboard with this idea. We just need to check if the hidden inputs already exist (within the form) before creating them.

I don't have time to implement this myself right now, but I would welcome a pull request.