diff --git a/src/Snaptcha.php b/src/Snaptcha.php index b35d83a..6653840 100644 --- a/src/Snaptcha.php +++ b/src/Snaptcha.php @@ -105,6 +105,7 @@ public function validateField(ActionEvent $event) $variables = [ 'errorTitle' => $this->settings->errorTitle, 'errorMessage' => $this->settings->errorMessage, + 'errorJavascriptDisabled' => $this->settings->errorJavascriptDisabled, 'errorButtonText' => $this->settings->errorButtonText, 'postedValues' => Craft::$app->request->getBodyParams(), ]; diff --git a/src/config.php b/src/config.php index 541f6f2..e092dc2 100755 --- a/src/config.php +++ b/src/config.php @@ -32,7 +32,10 @@ //'fieldName' => 'snaptcha', // The error message that will be displayed if Snaptcha identifies a submission as spam. - //'errorMessage' => 'Sorry, you have failed the security test. Please ensure that you have javascript enabled and that, you refresh the page that you are trying to submit.' + //'errorMessage' => 'For some reason your submission was flagged as spam. Please click the button below to resubmit your data.' + + // The error that will be displayed if Snaptcha identifies a submission as spam and JavaScript is disabled. + //'errorJavascriptDisabled' => 'JavaScript must be enabled for your submission to be verified. Please enable it and refresh the page.' // The text that will be displayed in the button if Snaptcha identifies a submission as spam. //'errorButtonText' => 'Click this button to resubmit the form.', diff --git a/src/models/SettingsModel.php b/src/models/SettingsModel.php index 5c139ee..cb38d00 100644 --- a/src/models/SettingsModel.php +++ b/src/models/SettingsModel.php @@ -37,7 +37,12 @@ class SettingsModel extends Model /** * @var string */ - public $errorMessage = 'For some reason your submission was flagged as spam. Please ensure that you have JavaScript enabled and click the button below to resubmit your data.'; + public $errorMessage = 'For some reason your submission was flagged as spam. Please click the button below to resubmit your data.'; + + /** + * @var string + */ + public $errorJavascriptDisabled = 'JavaScript must be enabled for your submission to be verified. Please enable it and refresh the page.'; /** * @var string diff --git a/src/templates/_error.html b/src/templates/_error.html index bd81b1f..caafd72 100644 --- a/src/templates/_error.html +++ b/src/templates/_error.html @@ -2,12 +2,23 @@ {% set title = errorTitle %} +{% js %} + document.getElementById('warning').remove(); + document.getElementById('error').classList.remove('hidden'); + document.getElementById('resubmit').classList.remove('disabled'); +{% endjs %} {% block message %}

{{ errorTitle }}

-

{{ errorMessage }}

+ + +

+ {{ errorJavascriptDisabled }} +

{% for name, value in postedValues %} @@ -16,7 +27,7 @@

{{ errorTitle }}

{{ craft.snaptcha.field }} -
diff --git a/src/templates/_settings.html b/src/templates/_settings.html index 48282ed..e94e37d 100644 --- a/src/templates/_settings.html +++ b/src/templates/_settings.html @@ -70,6 +70,16 @@ errors: settings.getErrors('errorMessage') }) }} +{{ forms.textField({ + required: true, + label: 'Error JavaScript Disabled'|t('snaptcha'), + name: 'errorJavascriptDisabled', + instructions: 'The error that will be displayed if Snaptcha identifies a submission as spam and JavaScript is disabled.'|t('snaptcha'), + warning: (config.errorMessage is defined ? configWarning('errorJavascriptDisabled')), + value: settings.errorJavascriptDisabled, + errors: settings.getErrors('errorJavascriptDisabled') +}) }} + {{ forms.textField({ required: true, label: 'Error Button Text'|t('snaptcha'),