Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Edgar Rasquin 326 posts 925 karma points
    May 27, 2021 @ 10:51
    Edgar Rasquin
    0

    jQuery Validation equalTo - comparing two email addresses

    Hi,

    I need to implement an additional input field to compare the email address on VendrChoutInformationPage.cshtml.

    Since Vendr Checkout uses jQuery Validation I thought that it could not be to hard to implement. But I had so far no luck.

    Here is what I have done so far:

    First I added an Id to the form so that I can address it

    @using (Html.BeginUmbracoForm("UpdateOrderInformation", "VendrCheckoutSurface", new { @id = "checkoutInformationForm" }))
    

    Than I added an extra email2 input field to the form

    <input name="email2" type="email" placeholder="Email check" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full"
           value="" required />
    

    Than I added an extra Id to the existing email input field so I can address it

    <input name="email" type="email" placeholder="Email" id="email" class="block placeholder-gray-700 border border-gray-300 rounded py-2 px-4 mb-2 w-full"
           value="@(currentOrder.CustomerInfo.Email)" required />
    

    Than I added this code to VendrCheckoutInformationPage.cshtml

       @section foot
    {
        <script>
            $(document).ready(function() {
                $("#checkoutInformationForm").validate({
                    rules: {
                        email2: {
                            minlength: 1,
                            required: true,
                            equalTo: '#email'
                        }
                    }
                });
            });
        </script>
    }
    

    It does not work.

    Any ideas?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    May 27, 2021 @ 18:05
    Huw Reddick
    1

    you need to add email2 as an id to your email2 input, jquery uses id's not names

Please Sign in or register to post replies

Write your reply to:

Draft