Squarespace unique identifier solution no longer works due to change in form. Need help to determine why it wont work/solution
SS=Square Space
Previously there was a script posted by Ian_A on the SS forums to add in a unique identifier on forms submitted to prevent collation of emails in gmail. This enabled us to reply to each received form by hitting reply without needing to alter our default gmail box to conversation view etc.
We cannot change our gmail settings. (cannot turn on conversation view without alienating some users)
SS have since changed how the forms work and I believe that the $ parameter of the script no longer targets the correct part of the field. I don't have a coding background, my limited understanding is that the $ is the way jquery selects the field. I am not sure how to structure the jquery selector to pick the field I want by perhaps the class ID which is unique to each field on the form.
There is only one form to make this work on. I only have access to header code injection and custom CSS. I need each email sent by the form to have a randomised subject (or time/date stamped)
Below is the example of the code that worked prior to SS updating the site.
<script>
$(document).ready(function(){
var timecode = Date.now();
var subjecttxt = "#" + timecode;
$('form').find("input[type=text], text").each(function()
{
if(!$(this).val()) {
$(this).attr("value", subjecttxt);
$(this).attr("readonly", true);
$(this).css("display","none");
var val = subjecttxt;
return ( val !== subjecttxt );
}
});
});
$(document).ready(function(){
$('form').find("label[class=title]").each(function()
{
if(!$(this).val()) {
$(this).css("display","none");
var val2 = "none";
return ( val2 !== "none" );
}
});
});
</script>
Source= SS Forum Post Our website contact us page= Form in question
Below is the information I can see relating to the blank subject text box I both wish to hide from the user and autofill with a unique identifier on send so that we can identify each send individually. I feel there should be a way with jquery to get it to pick this instead of the just the first field on the form which no longer works, but I can't work out how to change the previous code above, to make it work and despite testing can't see why it wont work (no errors throw on the page load and I don't know how else to check)
For example: $('form') .find(input.text-dfd9bd71-70a1-413d-81f2-dae19bb38da2 )
I know this doesn't work but I don't know why it doesn't work, I feel like it could use the div id, or class but idk how to make jquery do that and the documentation is above my understanding currently.
<div id="text-dfd9bd71-70a1-413d-81f2-dae19bb38da2" class="form-item field text">
<label class="title" for="text-dfd9bd71-70a1-413d-81f2-dae19bb38da2-field">
Subject
</label>
<input
class="field-element text"
type="text"
id="text-dfd9bd71-70a1-413d-81f2-dae19bb38da2-field"
/>
</div>
I tried to hide a section at the top of a Squarespace contact form and have jquery select the box adding in a unique identifier.
Due to a change in the SS forms this no longer works as expected.
Comments
Post a Comment