Support Article
Screen does not focus on error containing field on submit
SA-100981
Summary
When a Validation is added to a property and an invalid field submitted, the Validation error does not receive focus automatically.
Error Messages
Not Applicable
Steps to Reproduce
- Add validation on a property.
- On Submit, ensure that the property value fails validation. Error displays at the top section of the screen. However, the focus is not on the error.
Root Cause
This behavior is as per Pega product design.
Resolution
Perform the following local-change:
- Add a Run Script on the Submit button and provide the setFocusOnErrorList function.
- Add the below script to the UserWorkForm. In the JavaScript API, invoke the setFocusOnErrorList() function:
<script>
function setFocusOnErrorList(){
setTimeout(function(){
var e = document.getElementsByClassName("iconErrorDiv");
e = e[0];
if(e && e.firstChild){
e.parentNode.tabIndex = "0";
e.parentNode.focus();
}
},5000);
}
</script>
Published February 12, 2020 - Updated December 2, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.