Skip to main content
4 of 4
added 429 characters in body
Prince Patel
  • 22.9k
  • 10
  • 98
  • 121

Create customer_account_create.xml at

app/code/MyModulespace/ModuleName/view/frontend/layout/customer_account_create.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="MyModulespace_ModuleName::js/myjs.js"/>
        <css src="MyModulespace_ModuleName::css/mycss.css" />
    </head>
</page>

Also, keep Magento_Customer in a sequence of your module

app/code/MyModulespace/ModuleName/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="MyModulespace_ModuleName" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Customer"/>
        </sequence>
    </module>
</config>

Add custom js via requirejs-config.js

app/code/MyModulespace/ModuleName/view/frontend/requirejs-config.js

var config = {
    map: {
        '*': {
            myjs:'MyModulespace_ModuleName/myjs'
        }
    }
};

app/code/MyModulespace/ModuleName/web/js/myjs.js

define('jquery', function($) {

    //Your custom js code here

    }(jQuery)
);

Then you can use custom js in registration template

<script>
// <![CDATA[
    require(['jquery','myjs'], function ($, myjs) {
        //Your code
    });
// ]]>
</script>
Prince Patel
  • 22.9k
  • 10
  • 98
  • 121