From ff5c7adc962832feb7082778e75f8ef14b0bfc76 Mon Sep 17 00:00:00 2001 From: Brent Rager Date: Mon, 29 Jun 2026 08:48:48 -0400 Subject: [PATCH] SMOODEV-2153: Phone formatting + validation on pre-chat form (libphonenumber-js, US) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pre-chat form's Phone field had no client-side formatting or validation — visitors typed free-form numbers and only the backend's E.164 normalization (smooai #2138) caught problems. This adds the frontend half so the field is self-explaining and the value we send is already canonical when it parses. - As-you-type formatting via AsYouType('US'). To avoid the standard AsYouType caret caveat (full-string reformat jumps the caret to the end), we only rewrite the value when the caret is at the end (the append-a-digit case) and never on a deletion — backspacing formatting characters works naturally. - Inline, themed validity hint driven by isValidPhoneNumber(value,'US'). Empty stays neutral (the field is optional unless requirePhone). - On submit: block + hint when requirePhone and the number is invalid; allow submit when optional. Send canonical E.164 (parsePhoneNumber.number) when it parses, else the raw value (the backend re-parses + normalizes/nulls). - Autofill preserved: type="tel", autocomplete="tel", and the implicit