diff --git a/public/js/vroom.js b/public/js/vroom.js index 6450a83..7912c67 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -498,6 +498,40 @@ function initIndex(){ }); } +// The feedback page +function initFeedback(){ + $('#email').on('input', function(){ + if (!$('#email').val().match(/\S+@\S+/) && $('#email').val() !== ''){ + $('#email').parent().addClass('has-error'); + } + else{ + $('#email').parent().removeClass('has-error'); + } + }); + + $('#comment').on('input', function(){ + if ($('#comment').val() === ''){ + $('#comment').parent().addClass('has-error'); + } + else{ + $('#comment').parent().removeClass('has-error'); + } + }); + + $('#feedback-form').submit(function(){ + var ok = true; + if ($('#email').parent().hasClass('has-error')){ + ok = false; + $('#email').notify(localize('ERROR_MAIL_INVALID'), 'error'); + } + if ($('#comment').parent().hasClass('has-error') || $('#comment').val() === ''){ + ok = false; + $('#comment').notify(localize('ERROR_COMMENT_INVALID'), 'error').parent().addClass('has-error'); + } + return ok; + }); +} + // The documentation page function initDoc(){ diff --git a/templates/default/feedback.html.ep b/templates/default/feedback.html.ep index 470ded4..2de1deb 100644 --- a/templates/default/feedback.html.ep +++ b/templates/default/feedback.html.ep @@ -3,7 +3,7 @@ %= include 'public_toolbar'
-
+ %= l('GIVE_US_YOUR_FEEDBACK') @@ -15,7 +15,7 @@ - + placeholder="<%= l('VROOM_IS_AWESOME') %>">
%= include 'js_common' + %= include 'footer' diff --git a/vroom.pl b/vroom.pl index 5dbe8d0..79bf3f8 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1487,7 +1487,14 @@ any [ qw(GET POST) ] => '/feedback' => sub { page => 'feedback' ); } - my $email = $self->param('email') || ''; + my $email = $self->param('email'); + if ($email && $email ne '' && !$self->valid_email($email)){ + return $self->render('error', + err => 'ERROR_MAIL_INVALID', + msg => $self->l('ERROR_MAIL_INVALID'), + room => '' + ); + } my $comment = $self->param('comment'); my $sent = $self->mail( to => $config->{'email.contact'},