Prevent hidden fields from taking up space on form | Community
Skip to main content
March 1, 2017
Solved

Prevent hidden fields from taking up space on form

  • March 1, 2017
  • 1 reply
  • 8163 views

Hello Community,

Does anyone have any experience with creating hidden fields on a Marketo form that do not take up any space on the form HTML? Right now, when I create a hidden field, it is hidden, but is still producing a  div.mktoFormRow which is pushing the div.mktoButtonRow down 10px per field. Is there someway to prevent this default wrapping? Or to just insert the hidden field before the end of the form? 

Thank you in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Changing the widths of the parents of input:hidden elements from 100% to 0px.


MktoForms2.whenReady(function(form){

    var formEl = form.getFormElem()[0],

            hiddenEls = formEl.querySelectorAll('.mktoFormRow INPUT[type="hidden"]');

  

    [].forEach.call(hiddenEls,function(el){

        el.parentNode.style.width = '0';

    });

});

1 reply

SanfordWhiteman
New Participant
March 1, 2017

INPUT[type="hidden"] {

  margin-bottom: 0 !important;

}

March 1, 2017

Thank you for your reply, Sanford. This does remove the 10px margin-bottom, but the div is still taking up space and pushing the button down. Any other thoughts?