Jump to content

Issue with Pre-filled forms

Go to solution Solved by MattBrown,

Recommended Posts

Posted

Hey There,

I have run into an issue with Squarespace's javascript related to forms. On our site, I have custom code to pre-fill user information into some forms. Here is a basic example:

$(document).ready(function() {
  var myForms = document.getElementsByClassName('form-wrapper');
		for (var i=0; i < myForms.length; i++) {
			formFiller(myForms[i]);
        }
});

function formFiller(thisForm) {
       //console.log(thisForm);
        var myInputs = thisForm.getElementsByTagName('Input');
        for (var j=0; j < myInputs.length; j++) {
	      if (myInputs[j].name === 'fname') myInputs[j].value = "Matt";
	      if (myInputs[j].name === 'lname') myInputs[j].value = "Brown";
	      if (myInputs[j].type === 'email')	myInputs[j].value = "admin@";
        }
}

Unfortunately, starting sometime this last spring, Squarespace's javascript code related to forms will delete any pre-filled data as soon as a user enters any characters into any of the form items in the same form.

You can see an example of this here:
https://www.crescentproject.org/test3

I have tried listening for changes to the form items and re-filling them but they are deleted again by Squarespace's javascript and looks really odd from a user point of view.

Squarespace support was able to reproduce the issue (which was appreciated) but then asserts that it is a user code issue, so not their problem.

Does anyone have suggestions for a work-around or how to address this with Squarespace so they will fix their bug?

Thanks
Matt

  • Replies 4
  • Views 790
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted

Update - the issue is getting forwarded on to engineering to have a look at.

Still - it would be great to have a work-around if there are any suggestions.

Posted
1 hour ago, MattBrown said:

starting sometime this last spring, Squarespace's javascript code related to forms will delete any pre-filled data. Does anyone have suggestions for a work-around or how to address this with Squarespace so they will fix their bug?

This isn’t a bug. In May, Squarespace replaced the form block with a new React based form and this means you cannot set the value in this way. React won’t be aware of the change (it is only a change to the DOM). 

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • 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.