|||

Workaround for Email Validation Issue in Statamic

Through a failed Horizon job I found out about the following: A user had entered an email address with an accidental space before the @ symbol. This caused the email to not be able to be sent and the Horizon job to fail.

Apparently, according to some email spec, spaces are allowed in the front part of an email address (before the @ symbol), and Laravel’s validation follows that (and as such, Statamic’s forms as well).

I got it resolved in the following way:

  1. Convert all email fields to input type="email" (should have been so before).
  2. Disable native form validation (otherwise browser validation would nag about the space before we can strip it).
  3. In the script that handles async sending, iterate over all fields of type="email" and strip any space that might be present in its value.
sendForm: async function() {
    // ...

    // Get the value of each input type email
    document.querySelectorAll('form input[type="email"]').forEach(
        function(item) {
            // Strip all spaces from the item's value
            item.value = item.value.replace(/\s/g, '');
        }
    );
    // ...
}
Up next A First Quick Look at Cosmos.so – and Why I'll Stick with MyMind Cosmos.so is an inspiration capture system marketing itself as an alternative to Pinterest. There is quite some overlap with the features offered by Using the AVIF format for CSS background images Today I learned that browser support for the AVIF image format has become excellent, with every major browser except Edge supporting it. As I’m
Latest posts Back to MyMind Sending Articles from Feedbin to Readwise Reader In Praise of Sublime App Why I Ended Up Using Todoist Yet Again Pros and Cons of Reflect Notes App A Love Letter to Sublime Internet Lazy.so is an amazing tool. Here's why I don't keep it Carl Sagan has shown the absurdity of not acting against climate change back in 1990 A success message that communicates the opposite of success Epomaker TH80 Pro Polyamor, aber mit PKM apps 🫣 Ironie, die Fabi Rommel Helft der Natur Tiny Garden Paradise Schwiegerfuchs Same Vibe Tailwind and Web Craftsmanship Buttons with CSS Expand Basic Markdown Formatting in Apple Notes Cannot Divide by Zero in Peak Picture Partial Applying a Growth Mindset (Doodle) Using the AVIF format for CSS background images Workaround for Email Validation Issue in Statamic A First Quick Look at Cosmos.so – and Why I'll Stick with MyMind Install a Starter Kit from local repo to get the latest Peak working in Statamic 4 beta Set sensible validations for Statamic image uploads Render first heading inside Statamic Page Builder as `h1` My PKM App Stack for 2023 Favorite apps in recent weeks: mymind & Craft First List Item inside CSS Multi Column Layout is offset