In the standard sale.order.ajax component, errors are displayed in the block of the section that the user fills in, for example, if the buyer has not filled in his details, then errors will appear in the Buyer block http://joxi.ru/KAg7BEJhgLyDxA . As I understand it, the main part of the component’s logic is placed in JS in the file order_ajax.js

In my cases all the blocks: Delivery Region, Buyer, etc., are separate tabs, http://joxi.ru/MAj7BRehvPNN0r and http://joxi.ru/ZrJOkEjH1jx71m . When the buyer goes to the last stage and presses the Place Order button, in case he didn’t fill in the first stage http://joxi.ru/MAj7BRehvPNN0r which were handed over, errors appear but they are displayed on the Buyer crease, i.e. it is not comfortable. I want to make a special block above the tabs and I will get errors so that they are not tied to the tabs. But the problem is that the error output is strictly tied to the sections of the form, which are displayed in my tabs.

How can you make errors appear in an arbitrary block? How can I override error output via JS using the Bitrix JS library?

    1 answer 1

    So in the file order_ajax.js pass all checks. More on the necessary functions:

    showValidationResult: function(inputs, errors)

    showErrorTooltip: function(tooltipId, targetNode, text) - Function in which tooltips are added for fields with an error.

    showError: function(node, msg, border) - Function in which errors are output to the “group container”

    refreshOrder: function(result) - A function in which the analysis of errors that come from the server occurs. There is a result.error branch

    The first 3 functions are responsible for validating the form without rebooting, and the fourth for processing the results from the server.

    For your task, you need to rewrite the showError function. The parameter msg - array is passed to this function and all errors on the form are stored in it.

    • Good afternoon, I ran into a problem in the custom catalog component template, on the detailed catalog page (catalog.element template of the integrated catalog component) the product is not added. As I understand, adding a product to the cart from the directory where the regular ajax works is tied to the DOM tree. The question is, if you make an ajax-addition based on the regular JS Bitrix, then you need to repeat in the layout all html-elements that are in the regular template? Is it possible to somehow exclude part of the DOM elements from the mandatory and specify only id-products, quantity and prices? - inviziblll