Replace a System Error Message with Custom Message - xmpie-users/uStore-js GitHub Wiki

Sometimes your users will receive generic system error messages that do not have the option to be localized.

In such a case, you can choose to replace the contents of the message based on its ID and a string that it contains.

In the following example, the element ID is ValidationSummary1 with the string that we are looking for is IncludeExceptionDetailInFaults and the message that will be displayed is "Please contact your representative."

The if condition also checks that the element is not null or undefined, in order to avoid possible errors.

<script type="text/javascript">
$( document ).ready(function() {
	var elem = document.getElementById('ValidationSummary1');
	if(typeof elem !== 'undefined' && elem !== null && elem.innerHTML.indexOf("IncludeExceptionDetailInFaults") !== -1) {
		elem.innerHTML = "Please contact your representative.";
	}
});
</script>

For information on how to add JavaScript to your store: How to add JavaScript to a storefront.

⚠️ **GitHub.com Fallback** ⚠️