How to show/hide elements using javascript equivalent to jQuery.show() and hide() DOM?

You can show or hide specific elements with native javascript without using jQuery.

<div class="mydiv">Content Goes here</div>

Continue reading “How to show/hide elements using javascript equivalent to jQuery.show() and hide() DOM?”

How to add custom validation rule in javascript using magento 2?

You can add a new validation rule with the data-validate attribute of the HTML tag using Magento.

By Default Magento mage/validation.js file used to set out-of-the-box custom rules for the Magento. Most of the times custom rules are used in the input tags. though you can apply to form tag, select tag as well as any HTML tag.

Syntax:
$.validator.addMethod(argument1, argument2, argument3) used to define custom validation rule in Magento. Continue reading “How to add custom validation rule in javascript using magento 2?”

How to update cart total summary section using js Magento 2?

You can reload or update cart total summary sidebar section in Magento by using Magento_Checkout/js/action/get-totals file.

A get-totals.js file used to reload a cart summary block on the cart page. Continue reading “How to update cart total summary section using js Magento 2?”