How to fix TypeError: target.extend is not a function mixins in Magento 2?

I am working on the checkout page store locator popup modal, I have tried to mixins for the pickup-locations-service.js file to override core methods from the javascript file.

The error TypeError: target.extend is not a function in Magento 2 often occurs due to issues with JavaScript mixins declaration.

Due to incorrect syntax in my custom mixins javascript file, I got the error in the browser console file,

target.extend is not a function.

This error came due to invalid syntax in your mixins file. you need to fix the mixins JS file to resolve that error. Continue reading “How to fix TypeError: target.extend is not a function mixins in Magento 2?”

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?”