From 0b43e4d918cef2f10634cb7592ce5f852da4c214 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 1 Jan 2016 20:18:03 +0100 Subject: [PATCH] Changed the CAPTCHA failure display (added input hint below the captcha input). --- src/application/controllers/appointments.php | 6 +++++- src/application/views/appointments/book.php | 1 + src/assets/css/frontend.css | 2 ++ src/assets/js/frontend_book.js | 18 +++++++++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index a8fd125e..14d09e20 100755 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -339,7 +339,11 @@ class Appointments extends CI_Controller { // Validate the CAPTCHA string. if ($this->settings_model->get_setting('require_captcha') === '1' && $this->session->userdata('captcha_phrase') !== $_POST['captcha']) { - throw new Exception($this->lang->line('captcha_is_wrong')); + echo json_encode(array( + 'captcha_verification' => FALSE, + 'expected_phrase' => $this->session->userdata('captcha_phrase') + )); + return; } // Check appointment availability. diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index c85902ca..6862f80f 100644 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -373,6 +373,7 @@ +   diff --git a/src/assets/css/frontend.css b/src/assets/css/frontend.css index 87cbccb8..d612e26d 100644 --- a/src/assets/css/frontend.css +++ b/src/assets/css/frontend.css @@ -198,6 +198,8 @@ body { #book-appointment-wizard .captcha-image { float: right; margin-bottom: 20px; + border-radius: 3px; + box-shadow: 1px 1px 4px rgba(0,0,0,0.4); } #book-appointment-wizard .captcha-text { diff --git a/src/assets/js/frontend_book.js b/src/assets/js/frontend_book.js index b02abf20..26f772a5 100644 --- a/src/assets/js/frontend_book.js +++ b/src/assets/js/frontend_book.js @@ -620,7 +620,7 @@ var FrontendBook = { if ($captchaText.length > 0) { $captchaText.css('border', ''); if ($captchaText.val() === '') { - $captchaText.css('border', '1px solid red'); + $captchaText.css('border', '1px solid #dc3b40'); return; } } @@ -668,6 +668,22 @@ var FrontendBook = { return false; } + if (response.captcha_verification === false) { + $('#captcha-hint') + .text(EALang['captcha_is_wrong'] + '(' + response.expected_phrase + ')') + .fadeTo(400, 1); + + setTimeout(function() { + $('#captcha-hint').fadeTo(400, 0); + }, 3000); + + $('.captcha-title small').trigger('click'); + + $captchaText.css('border', '1px solid #dc3b40'); + + return false; + } + window.location.replace(GlobalVariables.baseUrl + '/index.php/appointments/book_success/' + response.appointment_id); })