I am having an issue with some code I wrote. What I am doing is, I am creating an eCommerce checkout page and I have three different sections. 1. Shipping info 2. Billing info 3. Order confirmation info
The code I wrote is to basically to copy what was written in the shipping info section and show it in the order confirmation section farther down the page, so they can confirm that before ordering. The way I have it, it works great if the information in the shipping info form was typed in normally. But, if the customer double clicks in one of the input fields and allows the browsers auto-complete fill in the information, then this disables my code and it will not show up in the order confirmation info part.
<div class="field">
<label class="paddingleft" for="fullname">Full Name</label>
<div class="center">
<input type="text" class="biginputbarinline preview" id="ShipToFullname" data-copy="#name" name="ShipToFullname" required>
</div>
</div>
<div class="field">
<label class="paddingleft" for="streetline1">Street Line 1</label>
<div class="center">
<input type="text" class="biginputbarinline preview" id="ShipTostreetline1" data-copy="#address1" name="ShipTostreetline1" required>
</div>
</div>
This is where I show the code later down the page. This will not show up if the browser autocomplete was done when entering the shipping info.
<p>Shipping to:</p>
<p><div id="name"></div></p>
<p><div id="address1"></div></p>
JQuery
<script>
$(document).ready(function() {
$(".preview").on('keyup', function() {
$($(this).data('copy')).html($(this).val());
});
});
</script>
Is there any way I can change this, so that it works either way?
Per the comment that this is a duplicate - Ideally I'm not looking to disable the auto fill feature as it is a great feature. I want my code to work with it.