Error Message box instead of alert()

This commit is contained in:
Flavio Copes 2015-10-07 22:27:06 +02:00
parent c0a003ccda
commit adc6d19022
1 changed files with 21 additions and 4 deletions

View File

@ -17,18 +17,21 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
var captcha = $('#g-recaptcha-response').val(); var captcha = $('#g-recaptcha-response').val();
if (text.length == 0 || email.length == 0 || name.length == 0) { if (text.length == 0 || email.length == 0 || name.length == 0) {
alert('Please fill all the fields'); $('.alert').html('Please fill all the fields');
$('.alert-container').show();
return; return;
} }
if (!validateEmail(email)) { if (!validateEmail(email)) {
alert('Please enter a valid email'); $('.alert').html('Please enter a valid email');
$('.alert-container').show();
return; return;
} }
{% if use_captcha %} {% if use_captcha %}
if (!captcha) { if (!captcha) {
alert("Error validating the security code"); $('.alert').html("Error validating the security code");
$('.alert-container').show();
return; return;
} }
{% endif %} {% endif %}
@ -47,10 +50,12 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
type: 'POST' type: 'POST'
}) })
.success(function() { .success(function() {
$('.alert-container').hide();
window.location.reload(); window.location.reload();
}) })
.error(function() { .error(function() {
alert("Error while posting the comment"); $('.alert').html("Error while posting the comment");
$('.alert-container').show();
}); });
}); });
</script> </script>
@ -76,6 +81,18 @@ jQuery(document).on('click tap', '.js__add-new-comment', function(event) {
</script> </script>
{% endif %} {% endif %}
<div class="alert-container" style="display: none">
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p class="alert"></p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</div>
<form> <form>
<textarea class="js__new-comment-text"></textarea> <textarea class="js__new-comment-text"></textarea>
Name: <input type="text" class="js__new-comment-name" /> Name: <input type="text" class="js__new-comment-name" />