Support » Plugin: Email Subscribers & Newsletters - Simple and Effective newsletter system » "There was a problem with the request" error when FORM is submit with RETURN key

  • Pel

    (@pelstudio)


    We believe we have discovered a bug. If a user hits RETURN on an email field (instead of clicking SUBMIT button) a pop-up appears with the following message:

    There was a problem with the request.

    However, the FORM is still posted and the email is processed with no issue. This seems to be because the email input field has the following event defined:

    onkeypress="if(event.keyCode==13) es_submit_pages('<SITE URL>')"

    Instead, it should be:

    onkeypress="if(event.keyCode==13) return es_submit_pages('<SITE URL>')"

    AND the plugin should prevent the RETURN key from initiating a form submit.

    For now, we have resolved this issue with the following Javascript:

    jQuery("#es_txt_email_pg").removeAttr("onkeypress");
    
    jQuery('#es_txt_email_pg').on('keyup keypress', function(e) {
       var keyCode = e.keyCode || e.which;
       if (keyCode === 13) {
          e.preventDefault();
          return false;
       }
    });
    
    jQuery('#es_txt_email_pg').bind('keypress', function(e) {
    	if(e.keyCode==13){
    	   return es_submit_pages('<SITE URL>');
    	}
    });

    https://wordpress.org/plugins/email-subscribers/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author storeapps

    (@storeapps)

    @pelstudio,

    Thank you for bringing this to our notice. We’ll have a look at this & will fix in later releases.

    Pel

    (@pelstudio)

    Note for anyone else following along in case this may be of help. We added the following code to prevent the Return key from submitting the form in Chrome.

    jQuery('form').bind("keypress", function (e) {
       if (e.keyCode == 13) return false;
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘"There was a problem with the request" error when FORM is submit with RETURN key’ is closed to new replies.