How to add phone mask to checkout page in magento2?Magento 2 - Form ValidationStop Magento from cleaning phone number in checkoutI need add button link to a new page in Success.phtml (checkout process), how do I?Magento 2: How to add Class on Checkout Page?Checkout page phone number validationHow add mask to input with knockout javascript?Magento2 Checkout page adding buttton after phone numberHow Can I add a jquery mask to zip code input in cart?how to add content in checkout page magento 2?How To Customize Checkout Page Using One Page Checkout extension Call IWD Agency Magento 2.2.6my 2.2.6 magento checkout page do not display firstname,postcode,and telephone input field

How far can gerrymandering go?

Does the Grothendieck group of finitely generated modules form a commutative ring where the multiplication structure is induced from tensor product?

Why is quantum gravity non-renormalizable?

Classify 2-dim p-adic galois representations

I agreed to cancel a long-planned vacation (with travel costs) due to project deadlines, but now the timeline has all changed again

Wings for orbital transfer bioships?

*p++->str : Understanding evaluation of ->

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

Why doesn't SpaceX land boosters in Africa?

What is the point of using the kunai?

Could citing a database like libgen get one into trouble?

What is the function of const specifier in enum types?

What is the meaning of ゴト in the context of 鮎

When does it become illegal to exchange bitcoin for cash?

Confusion in understanding the behavior of inductor in RL circuit with DC source

What prevents a US state from colonizing a smaller state?

Installed software from source, how to say yum not to install it from package?

Why is the saxophone not common in classical repertoire?

How can I change my buffer system for protein purification?

Which high-degree derivatives play an essential role?

A world with roman numeral alphabet

Why can't i use !(single pattern) in zsh even after i turn on kshglob?

Is it advisable to inform the CEO about his brother accessing his office?

What happened to the Apollo 1 rocket?



How to add phone mask to checkout page in magento2?


Magento 2 - Form ValidationStop Magento from cleaning phone number in checkoutI need add button link to a new page in Success.phtml (checkout process), how do I?Magento 2: How to add Class on Checkout Page?Checkout page phone number validationHow add mask to input with knockout javascript?Magento2 Checkout page adding buttton after phone numberHow Can I add a jquery mask to zip code input in cart?how to add content in checkout page magento 2?How To Customize Checkout Page Using One Page Checkout extension Call IWD Agency Magento 2.2.6my 2.2.6 magento checkout page do not display firstname,postcode,and telephone input field













2















I need to add a mask to telephone on a checkout page, like +9-(999)-999-99-99.










share|improve this question
























  • magento.stackexchange.com/questions/95171/…

    – lalit mohan
    Apr 26 '18 at 13:47















2















I need to add a mask to telephone on a checkout page, like +9-(999)-999-99-99.










share|improve this question
























  • magento.stackexchange.com/questions/95171/…

    – lalit mohan
    Apr 26 '18 at 13:47













2












2








2








I need to add a mask to telephone on a checkout page, like +9-(999)-999-99-99.










share|improve this question
















I need to add a mask to telephone on a checkout page, like +9-(999)-999-99-99.







magento2 onepage-checkout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 26 '18 at 15:50









lalit mohan

7576 silver badges29 bronze badges




7576 silver badges29 bronze badges










asked Sep 6 '17 at 8:47









AbsAbs

112 bronze badges




112 bronze badges












  • magento.stackexchange.com/questions/95171/…

    – lalit mohan
    Apr 26 '18 at 13:47

















  • magento.stackexchange.com/questions/95171/…

    – lalit mohan
    Apr 26 '18 at 13:47
















magento.stackexchange.com/questions/95171/…

– lalit mohan
Apr 26 '18 at 13:47





magento.stackexchange.com/questions/95171/…

– lalit mohan
Apr 26 '18 at 13:47










3 Answers
3






active

oldest

votes


















0














If by mask you mean format it like that



so change 99999999999 to +9-(999)-999-99-99



then you could write a simple php format function something like:



$data = '+11234567890';

if( preg_match( '/^+d(d3)(d3)(d4)$/', $data, $matches ) )

$result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
return $result;



and then change the pattern to your liking






share|improve this answer






























    0














    Why don't you take a look at at this jQuery Mask plugin? Include the script in the head of your website and then call the following below the input field:



    $('#billing:telephone').mask('+0-(000)-000-00-00');





    share|improve this answer






























      0














      Hope it help you..
      http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_zip.html




      Please edit in these file in your module




      Add the following in vendormagentomodule-checkoutviewfrontendlayoutcheckout_index_index.xml



      example: magento2root/app/code/VendorName/ModuleName/view/frontend/layout/checkout_index_index.xml



      <item name="telephone" xsi:type="array">
      <item name="validation" xsi:type="array">
      <item name="customValidate" xsi:type="string">true</item>
      </item>
      </item>


      Add custom validation as per your need in




      vendormagentomagento2-baselibwebmagevalidation.js




      "customValidate": [
      function (phone_number, element) ,
      'Please specify a valid mobile number with country code example +9-(999)-999-99-99'
      ],


      Add following in




      vendormagentomodule-uiviewbasewebjslibvalidationrules.js




      "customValidate": [
      function(value)
      return value.length > 9 && value.match(/([+]?d1,2[.-s]?)?(d3[.-]?)2d4/g) && value.match(/^[-+]?[0-9]+$/);
      ,
      $.mage.__('Please specify a valid mobile number')
      ],





      share|improve this answer



























        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "479"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f192152%2fhow-to-add-phone-mask-to-checkout-page-in-magento2%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        If by mask you mean format it like that



        so change 99999999999 to +9-(999)-999-99-99



        then you could write a simple php format function something like:



        $data = '+11234567890';

        if( preg_match( '/^+d(d3)(d3)(d4)$/', $data, $matches ) )

        $result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
        return $result;



        and then change the pattern to your liking






        share|improve this answer



























          0














          If by mask you mean format it like that



          so change 99999999999 to +9-(999)-999-99-99



          then you could write a simple php format function something like:



          $data = '+11234567890';

          if( preg_match( '/^+d(d3)(d3)(d4)$/', $data, $matches ) )

          $result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
          return $result;



          and then change the pattern to your liking






          share|improve this answer

























            0












            0








            0







            If by mask you mean format it like that



            so change 99999999999 to +9-(999)-999-99-99



            then you could write a simple php format function something like:



            $data = '+11234567890';

            if( preg_match( '/^+d(d3)(d3)(d4)$/', $data, $matches ) )

            $result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
            return $result;



            and then change the pattern to your liking






            share|improve this answer













            If by mask you mean format it like that



            so change 99999999999 to +9-(999)-999-99-99



            then you could write a simple php format function something like:



            $data = '+11234567890';

            if( preg_match( '/^+d(d3)(d3)(d4)$/', $data, $matches ) )

            $result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
            return $result;



            and then change the pattern to your liking







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 26 '18 at 14:33









            Pascal WientjesPascal Wientjes

            4324 silver badges11 bronze badges




            4324 silver badges11 bronze badges





















                0














                Why don't you take a look at at this jQuery Mask plugin? Include the script in the head of your website and then call the following below the input field:



                $('#billing:telephone').mask('+0-(000)-000-00-00');





                share|improve this answer



























                  0














                  Why don't you take a look at at this jQuery Mask plugin? Include the script in the head of your website and then call the following below the input field:



                  $('#billing:telephone').mask('+0-(000)-000-00-00');





                  share|improve this answer

























                    0












                    0








                    0







                    Why don't you take a look at at this jQuery Mask plugin? Include the script in the head of your website and then call the following below the input field:



                    $('#billing:telephone').mask('+0-(000)-000-00-00');





                    share|improve this answer













                    Why don't you take a look at at this jQuery Mask plugin? Include the script in the head of your website and then call the following below the input field:



                    $('#billing:telephone').mask('+0-(000)-000-00-00');






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 26 '18 at 15:01









                    Liam McArthurLiam McArthur

                    8092 gold badges13 silver badges37 bronze badges




                    8092 gold badges13 silver badges37 bronze badges





















                        0














                        Hope it help you..
                        http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_zip.html




                        Please edit in these file in your module




                        Add the following in vendormagentomodule-checkoutviewfrontendlayoutcheckout_index_index.xml



                        example: magento2root/app/code/VendorName/ModuleName/view/frontend/layout/checkout_index_index.xml



                        <item name="telephone" xsi:type="array">
                        <item name="validation" xsi:type="array">
                        <item name="customValidate" xsi:type="string">true</item>
                        </item>
                        </item>


                        Add custom validation as per your need in




                        vendormagentomagento2-baselibwebmagevalidation.js




                        "customValidate": [
                        function (phone_number, element) ,
                        'Please specify a valid mobile number with country code example +9-(999)-999-99-99'
                        ],


                        Add following in




                        vendormagentomodule-uiviewbasewebjslibvalidationrules.js




                        "customValidate": [
                        function(value)
                        return value.length > 9 && value.match(/([+]?d1,2[.-s]?)?(d3[.-]?)2d4/g) && value.match(/^[-+]?[0-9]+$/);
                        ,
                        $.mage.__('Please specify a valid mobile number')
                        ],





                        share|improve this answer





























                          0














                          Hope it help you..
                          http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_zip.html




                          Please edit in these file in your module




                          Add the following in vendormagentomodule-checkoutviewfrontendlayoutcheckout_index_index.xml



                          example: magento2root/app/code/VendorName/ModuleName/view/frontend/layout/checkout_index_index.xml



                          <item name="telephone" xsi:type="array">
                          <item name="validation" xsi:type="array">
                          <item name="customValidate" xsi:type="string">true</item>
                          </item>
                          </item>


                          Add custom validation as per your need in




                          vendormagentomagento2-baselibwebmagevalidation.js




                          "customValidate": [
                          function (phone_number, element) ,
                          'Please specify a valid mobile number with country code example +9-(999)-999-99-99'
                          ],


                          Add following in




                          vendormagentomodule-uiviewbasewebjslibvalidationrules.js




                          "customValidate": [
                          function(value)
                          return value.length > 9 && value.match(/([+]?d1,2[.-s]?)?(d3[.-]?)2d4/g) && value.match(/^[-+]?[0-9]+$/);
                          ,
                          $.mage.__('Please specify a valid mobile number')
                          ],





                          share|improve this answer



























                            0












                            0








                            0







                            Hope it help you..
                            http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_zip.html




                            Please edit in these file in your module




                            Add the following in vendormagentomodule-checkoutviewfrontendlayoutcheckout_index_index.xml



                            example: magento2root/app/code/VendorName/ModuleName/view/frontend/layout/checkout_index_index.xml



                            <item name="telephone" xsi:type="array">
                            <item name="validation" xsi:type="array">
                            <item name="customValidate" xsi:type="string">true</item>
                            </item>
                            </item>


                            Add custom validation as per your need in




                            vendormagentomagento2-baselibwebmagevalidation.js




                            "customValidate": [
                            function (phone_number, element) ,
                            'Please specify a valid mobile number with country code example +9-(999)-999-99-99'
                            ],


                            Add following in




                            vendormagentomodule-uiviewbasewebjslibvalidationrules.js




                            "customValidate": [
                            function(value)
                            return value.length > 9 && value.match(/([+]?d1,2[.-s]?)?(d3[.-]?)2d4/g) && value.match(/^[-+]?[0-9]+$/);
                            ,
                            $.mage.__('Please specify a valid mobile number')
                            ],





                            share|improve this answer















                            Hope it help you..
                            http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_zip.html




                            Please edit in these file in your module




                            Add the following in vendormagentomodule-checkoutviewfrontendlayoutcheckout_index_index.xml



                            example: magento2root/app/code/VendorName/ModuleName/view/frontend/layout/checkout_index_index.xml



                            <item name="telephone" xsi:type="array">
                            <item name="validation" xsi:type="array">
                            <item name="customValidate" xsi:type="string">true</item>
                            </item>
                            </item>


                            Add custom validation as per your need in




                            vendormagentomagento2-baselibwebmagevalidation.js




                            "customValidate": [
                            function (phone_number, element) ,
                            'Please specify a valid mobile number with country code example +9-(999)-999-99-99'
                            ],


                            Add following in




                            vendormagentomodule-uiviewbasewebjslibvalidationrules.js




                            "customValidate": [
                            function(value)
                            return value.length > 9 && value.match(/([+]?d1,2[.-s]?)?(d3[.-]?)2d4/g) && value.match(/^[-+]?[0-9]+$/);
                            ,
                            $.mage.__('Please specify a valid mobile number')
                            ],






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Apr 26 '18 at 15:16

























                            answered Apr 26 '18 at 15:01









                            lalit mohanlalit mohan

                            7576 silver badges29 bronze badges




                            7576 silver badges29 bronze badges



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Magento Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f192152%2fhow-to-add-phone-mask-to-checkout-page-in-magento2%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                                Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                                Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form