[IMP] survey : scroll up to first survey validation error

- Change the default value of the Validation Error message on
    the Date : "The answer you entered is not valid."
- If long page, click on next and one error, the page should go up
    to allow the visitor to see where the error is.

Task ID : 1911291
Closes PR #29054
This commit is contained in:
David Beguin
2019-01-23 13:02:56 +00:00
parent 8f486db52d
commit f2e2b6260b
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ class SurveyQuestion(models.Model):
validation_max_float_value = fields.Float('Maximum value')
validation_min_date = fields.Date('Minimum Date')
validation_max_date = fields.Date('Maximum Date')
validation_error_msg = fields.Char('Validation Error message', translate=True, default=lambda self: _("The answer you entered has an invalid format."))
validation_error_msg = fields.Char('Validation Error message', translate=True, default=lambda self: _("The answer you entered is not valid."))
# Constraints on number of answers (matrices)
constr_mandatory = fields.Boolean('Mandatory Answer')
constr_error_msg = fields.Char('Error message', translate=True, default=lambda self: _("This question requires an answer."))
+5
View File
@@ -145,6 +145,11 @@ if(!the_form.length) {
if(_.has(response, 'errors')){ // some questions have errors
_.each(_.keys(response.errors), function(key){
$("#" + key + '>.js_errzone').append('<p>' + response.errors[key] + '</p>').show();
if (_.keys(response.errors)[_.keys(response.errors).length - 1] === key) {
$('html, body').animate({
scrollTop: $('.js_errzone:visible:first').closest('.js_question-wrapper').offset().top - $('.o_main_navbar').height()
}, 500);
}
});
return false;
}