I want to display an error message on the form/listing in magento 2 back-end. I know how to show those message using a controller.

enter image description here

But how can i achieve same with JavaScript.

1 Answer 1


You can use Magento UI alert js for showing javascripts errors like this:

<script type="text/javascript">{
                    require(['Magento_Ui/js/modal/alert'], function (malert) {

                        function showErrorAlert() {
                                title: 'Error',
                                content: 'Some error occured. Please try again later.',
                                clickableOverlay: false,
                                actions: {
                                    always: function () {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.