NEW Add hidden option MAIN_MAILFORM_DISABLE_ENTERKEY to disable the key

enter into the form to send email.
This commit is contained in:
Laurent Destailleur
2015-06-04 12:57:49 +02:00
parent 331ebbdd73
commit fa01dc200d
4 changed files with 78 additions and 30 deletions

View File

@@ -275,7 +275,7 @@ class FormMail extends Form
$out.= "\n<!-- Debut form mail -->\n";
if ($this->withform == 1)
{
$out.= '<form method="POST" name="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<input style="display:none" type="submit" id="sendmail" name="sendmail">';
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
$out.= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />';
@@ -703,6 +703,23 @@ class FormMail extends Form
$out.= '</table>'."\n";
if ($this->withform == 1) $out.= '</form>'."\n";
// Disable enter key if option MAIN_MAILFORM_DISABLE_ENTER is set
if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY))
{
$out.= '<script type="text/javascript" language="javascript">';
$out.= 'jQuery(document).ready(function () {';
$out.= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is calle at every key pressed ! */
var code = e.keyCode || e.which;
if (code == 13) {
e.preventDefault();
return false;
}
});';
$out.=' })';
$out.= '</script>';
}
$out.= "<!-- Fin form mail -->\n";
return $out;