diff --git a/public/assets/javascript/app-public.js b/public/assets/javascript/app-public.js
index 5a05c9a5..b5b721d3 100644
--- a/public/assets/javascript/app-public.js
+++ b/public/assets/javascript/app-public.js
@@ -53,24 +53,9 @@ $(function() {
case 'error':
if (data.messages) {
- $.each(data.messages, function(index, error) {
-
- /*
- * use the class as the selector if the input name is an array.
- */
- var selector = (index.indexOf(".") >= 0) ? '.' + index.replace(/\./g, "\\.") : ':input[name=' + index + ']';
-
- $(selector, $form)
- .after('
' + error + '
')
- .parent()
- .addClass('has-error');
- });
+ processFormErrors($form, data.messages);
+ return;
}
-
-
- var $submitButton = $form.find('input[type=submit]');
- toggleSubmitDisabled($submitButton);
-
break;
default:
@@ -182,7 +167,8 @@ function processFormErrors($form, errors)
{
$.each(errors, function (index, error)
{
- var $input = $(':input[name=' + index + ']', $form);
+ var selector = (index.indexOf(".") >= 0) ? '.' + index.replace(/\./g, "\\.") : ':input[name=' + index + ']';
+ var $input = $(selector, $form);
if ($input.prop('type') === 'file') {
$('#input-' + $input.prop('name')).append('' + error + '
')
diff --git a/public/assets/javascript/frontend.js b/public/assets/javascript/frontend.js
index f46c74da..51e9182b 100644
--- a/public/assets/javascript/frontend.js
+++ b/public/assets/javascript/frontend.js
@@ -4621,24 +4621,9 @@ function log() {
case 'error':
if (data.messages) {
- $.each(data.messages, function(index, error) {
-
- /*
- * use the class as the selector if the input name is an array.
- */
- var selector = (index.indexOf(".") >= 0) ? '.' + index.replace(/\./g, "\\.") : ':input[name=' + index + ']';
-
- $(selector, $form)
- .after('' + error + '
')
- .parent()
- .addClass('has-error');
- });
+ processFormErrors($form, data.messages);
+ return;
}
-
-
- var $submitButton = $form.find('input[type=submit]');
- toggleSubmitDisabled($submitButton);
-
break;
default:
@@ -4750,7 +4735,8 @@ function processFormErrors($form, errors)
{
$.each(errors, function (index, error)
{
- var $input = $(':input[name=' + index + ']', $form);
+ var selector = (index.indexOf(".") >= 0) ? '.' + index.replace(/\./g, "\\.") : ':input[name=' + index + ']';
+ var $input = $(selector, $form);
if ($input.prop('type') === 'file') {
$('#input-' + $input.prop('name')).append('' + error + '
')