Dear support,
In one of my form, I have very long height page with browser vertical scrollbar. How to scroll top when error occur? so the focus will be at the error form control and leaving the button.
After hit save button and if error occur, I want the page scroll to top automatically leaving the button view so user will aware at to upper form there are something wrong (error occur)
Thank you in advance
Best regards,
Ismail
document.getElementById('formId').addEventListener('submit', function (e) {
e.preventDefault();
if (formObj.validate()) {
alert('Your form has been submitted.');
formObj.reset();
} else {
if (document.querySelectorAll('[aria-invalid="true"]')[0]) {
document.querySelectorAll('[aria-invalid="true"]')[0].focus();
}
}
});
|
Hi Indrajith,
Thank you for your reply, it's work like a charm.
Best regards,
Ismail
Hi Indrajith,
Additional question with same scenario, but for custom dialog modal? How to scroll top for custom dialog modal? because the validation is handled automatically by Grid:
Thank you,
Ismail
Index.js
actionComplete: function (args) {
if (args.requestType === 'add') { // while adding the record the focus will be changed to invalid input
args.dialog.ftrTemplateContent
.querySelector('.e-primary')
.addEventListener('click', (e) => {
var dialogEle = ej.grids.parentsUntil(e.target, 'e-dialog', false);
if (dialogEle) {
dialogEle.querySelector('[aria-invalid="true"]').focus();
}
});
……
} |
Hi Berly,
Thank you for your update. Your provided example work perfectly! It's awesome!:
Thank you for your kind support.
Best regards,
Ismail