Jump to content

BenjaminKern

Member
  • Posts

    4
  • Joined

  • Last visited

Reputation Activity

  1. Like
    BenjaminKern got a reaction from sorca_marian in Intercept Form with Required Fields   
    I have a Form setup, where I have custom javascript in place to hide required form elements, and populate them with jquery. This used to work, but now when the form is submitted, its reporting back as "Field is required" since the user themselves didn't type in the form field. 

    This had worked previously, but it seems like possibly Squarespace is using ReactJS that is preventing the value override from being recognized by the validating backend? Any help would be greatly appreciated.

    Only thought currently is to do the required field validation in custom js as well and mark the fields in the form as not required, thus bypassing whatever check is happening
  2. Like
    BenjaminKern reacted to sorca_marian in Intercept Form with Required Fields   
    I also found a little simpler way

     
    var input = document.querySelector("form input"); Object.defineProperty(input, "value", { value: "programmatically added value", writable: true }); var inputEvent = new Event('input', { bubbles: true}); input.dispatchEvent(inputEvent);  
  3. Like
    BenjaminKern got a reaction from sorca_marian in Intercept Form with Required Fields   
    After further triaging, I concur with "form state only seems to register the value when it is typed manually". Even if I remove the required validation, the fields I want to populate with jQuery are being ignored in the POST submission request. 

    I also tried to trigger change, focus, keydown events but nothing seemed to pickup the fact that the value had changed. Just local changes to the DOM it appears.
    I contacted customer support, but they basically said that platform updates are not guaranteed to continue working with custom code and recommended continuing the discussion here.
  4. Like
    BenjaminKern got a reaction from creedon in Intercept Form with Required Fields   
    Another thing to note in case others run into the same issue. It didn't seem to work with "Hidden" form block items (the input value was changing, but not being sent in the submission POST request payload), but I worked around that by using a text block item and then just manually hide it with jquery on page load.
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.