How can I prevent parts of a form on my page from submitting based on the width of the page?
i.e. if the page is between 900px
and 1200px
only form input/select items with class .regular-form
would be included in the form submission.
How can I prevent parts of a form on my page from submitting based on the width of the page?
i.e. if the page is between 900px
and 1200px
only form input/select items with class .regular-form
would be included in the form submission.
You can make sure that the relevant elements are not part of the DOM, and this will make sure they will also not sent in the submission.
You can use this code to do so:
if($(window).width() > 900 && $(window).width() < 1200) {
$('input,select,textarea').not('.regular-form').remove()
}
I don't know if you need to account for the window being dynamically resized or not, so a simple solution would be something like this:
if($(window).width() > 900 && $(window).width() < 1200)
{
$('.regular-form').prop('disabled', false);
}