Skip to content

Commit 24952f0

Browse files
committed
Added Smooth scroll for Parsley errors 📜
1 parent 556efcd commit 24952f0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎tmpl/default.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@
147147
scrollTop: $('#simple-contact-form-<?php echo $module->id; ?>').offset().top - 150
148148
}, 300);
149149
}
150+
151+
// Smooth Scroll to parsley errors
152+
$('#simple-contact-form-<?php echo $module->id; ?>').parsley().on('field:validated', function() {
153+
var errorNotice = $('ul.text-danger li');
154+
if ( errorNotice.length ) {
155+
$('html, body').animate({
156+
scrollTop: errorNotice.offset().top - 100
157+
}, 300);
158+
}
159+
});
160+
150161
$('#simple-contact-form-<?php echo $module->id; ?>').on('submit', function (e) {
151162
e.preventDefault();
152163
var formData = new FormData(this);

0 commit comments

Comments
 (0)