{"id":1530675,"date":"2018-05-15T06:38:38","date_gmt":"2018-05-15T13:38:38","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/"},"modified":"2018-05-15T19:49:06","modified_gmt":"2018-05-16T02:49:06","slug":"rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/","title":{"rendered":"RSVP multiple confirmation clicks code snippet causes problem for required field"},"content":{"rendered":"<p>We also had problems with multiple confirmations for RSVPs caused by double-clicking or multiple clicking before the form starts the submission process to the server. This is reported before here:<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"giMN31cRmS\"><p><a href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks\/\">RSVP multiple confirmation clicks<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;RSVP multiple confirmation clicks&#8221; &#8212; \" src=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks\/embed\/#?secret=HT8f6SwIbr#?secret=giMN31cRmS\" data-secret=\"giMN31cRmS\" width=\"580\" height=\"327\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>Cliff presented a code snippet to solve this problem in that thread. We also use that code snippet, but found that it causes problems when required fields are present and the user does not enter values (text) or select any value (for radiobuttons and checkboxes). In this case the form is not submitted, an error message is shown to the user, but the button&#8217;s click event (added by the code snippet) is also in place preventing any further submissions.<\/p>\n<p>We solved this and suggest that you update your code snippet like this:<\/p>\n<pre><code>\/**\r\n* Disable just the Submit button of the Event Tickets form after initial click to protect against sending data multiple times\r\n* From: gist.github.com\/cliffordp\/8bceb54b440fbe9de1d42df6f231cc7a\r\n* By Matt B.\r\n* Updated 2017-01-13 for latest versions of ET\/ET+\r\n* Updated 2018-05-15 by AndLen Re-enable button after 2s delay to enable it after an error message.\r\n**\/\r\nfunction tribe_snippet_prevent_multi_click_on_submit() {\r\nwp_enqueue_script( 'jquery' );\r\n?&gt;\r\n&lt;script&gt;\r\njQuery( function( $ ) {\r\nvar $button = $( '.tribe-events-tickets-rsvp button[name=\"tickets_process\"]' );\r\n$button.closest( 'form' ).on( 'submit', function( e ) {\r\n$button.on( 'click', function() { return false; } );\r\n\/\/ AndLen: Remove click handler (preventing further submissions) with 2 second delay after first click.\r\nsetTimeout(function(){$button.unbind('click');}, 2000);\r\n} );\r\n});\r\n&lt;\/script&gt;\r\n&lt;?php\r\n}\r\nadd_action( 'event_tickets_rsvp_before_confirmation_fields', 'tribe_snippet_prevent_multi_click_on_submit' );<\/code><\/pre>\n<p>The code adds a click handler to the submit button when the form is about to be submitted, preventing any more submissions when the button is clicked. Our addition removes this click handle after a 2 second delay to re-enable the button to allow submissions.<\/p>\n<p>We have tested this and it now functions correctly also after error messages. The specified delay, 2000 milliseconds in this case, may be adjusted. We found this value to be good enough for our site.<\/p>\n","protected":false},"template":"","class_list":["post-1530675","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RSVP multiple confirmation clicks code snippet causes problem for required field -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RSVP multiple confirmation clicks code snippet causes problem for required field -\" \/>\n<meta property=\"og:description\" content=\"We also had problems with multiple confirmations for RSVPs caused by double-clicking or multiple clicking before the form starts the submission process to the server. This is reported before here: RSVP multiple confirmation clicks Cliff presented a code snippet to solve this problem in that thread. We also use that code snippet, but found that [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-16T02:49:06+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/\",\"name\":\"RSVP multiple confirmation clicks code snippet causes problem for required field -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2018-05-15T13:38:38+00:00\",\"dateModified\":\"2018-05-16T02:49:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"RSVP multiple confirmation clicks code snippet causes problem for required field\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RSVP multiple confirmation clicks code snippet causes problem for required field -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/","og_locale":"en_US","og_type":"article","og_title":"RSVP multiple confirmation clicks code snippet causes problem for required field -","og_description":"We also had problems with multiple confirmations for RSVPs caused by double-clicking or multiple clicking before the form starts the submission process to the server. This is reported before here: RSVP multiple confirmation clicks Cliff presented a code snippet to solve this problem in that thread. We also use that code snippet, but found that [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/","article_modified_time":"2018-05-16T02:49:06+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/","name":"RSVP multiple confirmation clicks code snippet causes problem for required field -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2018-05-15T13:38:38+00:00","dateModified":"2018-05-16T02:49:06+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/rsvp-multiple-confirmation-clicks-code-snippet-causes-problem-for-required-field\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"RSVP multiple confirmation clicks code snippet causes problem for required field"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1530675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":5,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1530675\/revisions"}],"predecessor-version":[{"id":1531349,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1530675\/revisions\/1531349"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1530675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}