Ensure empty values are not submitted

Name attributes specify the name of particular html elements. In the case of gift messages obtained through Giftship, your customer may have filled in fields with name attributes such as ‘To’, ‘From’, and ‘Message’.

If you would like to remove these from being submitted, when empty, disabling the field before the form is submitted is the best way to do so.

To remove empty values from the form go to Online Store -> Themes -> Your Theme -> theme.liquid, and insert the following code above the closing </body> tag:


    (function() {

      var GSM = {

        init: function() {


        elements: {

          productForm: null,
          formSubmitButton: null,
        state: {

          form_handled: false

        assignElements: function() {

          GSM.elements.productForm = document.querySelector('form[action*="cart/add"]');
          GSM.elements.formSubmitButton = document.querySelector('button[id*="AddToCart--product-template"]');

        events: function() {

          GSM.elements.productForm.addEventListener('submit', GSM.functions.handleFormSubmit);

        functions: {

          handleFormSubmit: function(event) {

            if (GSM.state.form_handled === true) {
              return true;
            GSM.state.form_handled = true;



          removeAttributes: function() {

            var giftshipInputs = GSM.elements.productForm.querySelectorAll('.gs__product-element');

            giftshipInputs.forEach(function(el) {

              if (el.value !== "") return;

              el.setAttribute('disabled', 'disabled');


Can't find the answer in our documentation?
Contact Support