Jump to content

MuhammadIsa

Member
  • Posts

    16
  • Joined

  • Last visited

Reputation Activity

  1. Like
    MuhammadIsa got a reaction from tuanphan in Remove last name field in newsletter form only and change first name field to full name   
    Hey,
    I have a solution for this now:
    Add to Code Injection --> Footer
    <script> document.addEventListener('DOMContentLoaded', function() { const newsletterForm = document.querySelector('.newsletter-form-body'); const lnames = document.querySelectorAll('.last-name input'); const lnameFields = document.querySelectorAll('.last-name'); if (newsletterForm) { // Create the full name input field const fullNameInput = document.createElement('input'); fullNameInput.className = 'newsletter-form-field-element field-element field-control'; fullNameInput.name = 'fullname'; fullNameInput.type = 'text'; fullNameInput.spellcheck = 'false'; fullNameInput.placeholder = 'Full Name'; fullNameInput.maxLength = 60; fullNameInput.required = true; // Create the wrapper div for the full name input const fullNameWrapper = document.createElement('div'); fullNameWrapper.className = 'newsletter-form-field-wrapper form-item fields name required'; fullNameWrapper.style.verticalAlign = 'bottom'; // Create the label for the full name input const fullNameLabel = document.createElement('label'); fullNameLabel.className = 'newsletter-form-field-label title'; fullNameLabel.textContent = 'Full Name'; // Append the label and input to the wrapper div fullNameWrapper.appendChild(fullNameLabel); fullNameWrapper.appendChild(fullNameInput); // Find the existing first name and last name fields const firstNameField = newsletterForm.querySelector('.newsletter-form-field-wrapper.field.first-name'); const lastNameField = newsletterForm.querySelector('.newsletter-form-field-wrapper.field.last-name'); // Replace the first name field with the full name field if (firstNameField) { firstNameField.parentNode.replaceChild(fullNameWrapper, firstNameField); } // Hide the last name field and set its default value lnames.forEach(lname => { lname.value = "-"; }); lnameFields.forEach(lnameField => { lnameField.style.display = "none"; }); // Handle form submission newsletterForm.addEventListener('submit', function(event) { const fullName = fullNameInput.value.trim(); if (!fullName) { event.preventDefault(); alert('Please enter your full name.'); return; } // Split the full name into first name and last name const nameParts = fullName.split(' '); const firstName = nameParts[0]; const lastName = nameParts.slice(1).join(' ') || '-'; // Create hidden inputs for first name and last name if not already present let firstNameHiddenInput = newsletterForm.querySelector('input[name="fname"]'); let lastNameHiddenInput = newsletterForm.querySelector('input[name="lname"]'); if (!firstNameHiddenInput) { firstNameHiddenInput = document.createElement('input'); firstNameHiddenInput.type = 'hidden'; firstNameHiddenInput.name = 'fname'; newsletterForm.appendChild(firstNameHiddenInput); } if (!lastNameHiddenInput) { lastNameHiddenInput = document.createElement('input'); lastNameHiddenInput.type = 'hidden'; lastNameHiddenInput.name = 'lname'; lastNameHiddenInput.value = '-'; // Set a default value for last name newsletterForm.appendChild(lastNameHiddenInput); } firstNameHiddenInput.value = firstName; lastNameHiddenInput.value = lastName; }); } }); </script>  
  2. Thanks
    MuhammadIsa got a reaction from creedon in Customer Account Panel Change   
    Hey Thomas,
    Thank you! It works perfectly now.
    I have updated to v0.3.0 but I was still running v0.2.5 alongside it. I had accidentally added the callback to the old version.
    Thanks again for your immense help!
  3. Like
    MuhammadIsa reacted to creedon in Customer Account Panel Change   
    I have update my cited code.
    From the changes.
    support multiple callbacks Let me know how it goes.
  4. Love
    MuhammadIsa reacted to creedon in Customer Account Panel Change   
    You need to update to the latest version of my customer account panel change code. I thought you had updated to v0.3.0 but you are still running v0.2.5.
    Before you update you will want to make a copy of any customizations you added outside of your site so that you can apply the customizations back into the new version of the code.
    You'll also want to check the install instructions for the greeting code as how to add the callback to the customer account panel change code has changed a bit.
  5. Love
    MuhammadIsa reacted to creedon in Customer Account Panel Change   
    Please see the following.
  6. Love
    MuhammadIsa reacted to creedon in Customer Account Panel Change   
    I have update my cited code.
    From the changes.
    support digital products panel remove jQuery dependency Let me know how it goes.
  7. Like
    MuhammadIsa reacted to paul2009 in Adjusting social icons and currency selector position in header   
    Squarespace doesn't have a built-in currency converter, so this is being provided with a 'plugin'.
    This one isn't my currency plugin so I encourage you to reach out for help to the author of the plugin you purchased.
  8. Thanks
    MuhammadIsa got a reaction from creedon in Member Area Log In Dialog Change   
    Thank you @creedon!
  9. Thanks
    MuhammadIsa got a reaction from creedon in Member Area Log In Dialog Change   
    Yes it worked perfectly! Thank you so much Thomas!
  10. Thanks
    MuhammadIsa reacted to creedon in Member Area Log In Dialog Change   
    Please see MALIDC Join Quote.
    Let me know how it goes.
  11. Like
    MuhammadIsa reacted to creedon in Member Area Log In Dialog Change   
    My code currently does not distinguish between plain and member area sign up dialogs.


    They are basically the same dialog with just a few difference. So using the sign up variable in my code probably won't do for the effect you want.
    signUp : '[optional, enter sign up title text here between single quotes replacing square brackets]', What you want may be possible using a custom callback and using my accountFrameCallback variable per the instructions.
    accountFrameCallback : undefined I do not know of any custom callback code that does what you want.
    For our edification what text do you want in place of the default text?
×
×
  • 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.