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.68k stars 1.95k forks source link

strictMode not blocking type of incorect numbers #1804

Closed AzA-95 closed 2 months ago

AzA-95 commented 2 months ago

Plugin version

v24.5.0

Demo here https://jsfiddle.net/8r6j32Lm/

Steps to reproduce

  1. Typing with 98765432101 (format of typing works correct. Result is +7 987 654-32-10 with stopped fixed length without 1 in end)
  2. Typing with 56789012345 (format of typing works incorrect not apllied mask with dashed. Result is +7 5678901234 with stopped fixed length without 5 in end)
  3. Typing with 0000000000000000 (format of typing works incorrect not apllied mask with dashed and not works strictct of fixed length. Result is +7 0000000000000000 )

Expected behaviour

when typing 56789012345 expected +7 without any number because format incorect(not started with 9) when typing 0000000000000000 expected +7 without any number because format incorect(not started with 9)

Actual behaviour

when typing 98765432101 Result is +7 987 654-32-10 Works Correct when typing 56789012345 Result is +7 5678901234 when typing 0000000000000000 Result is +7 0000000000000000

Initialisation options

{
    strictMode: true,
    separateDialCode: true,
    initialCountry: "ru",
    utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@24.5.0/build/js/utils.js"
}
jackocnr commented 2 months ago

You say you expect typing "5" at the beginning of a Russian number to not work (to ignore the digit), because that is an invalid digit at that point in the number, but unfortunately strictMode is not that complex - all it does is ignore non-numeric characters and cap the number length, as per the readme. It would be much too complicated to block input of specific digits at specific points in the number.