javascript - Browser autocomplete not allowing copy/keyup function to work -


i having issue code wrote. doing is, creating ecommerce checkout page , have 3 different sections. 1. shipping info 2. billing info 3. order confirmation info

the code wrote copy written in shipping info section , show in order confirmation section farther down page, can confirm before ordering. way have it, works great if information in shipping info form typed in normally. but, if customer double clicks in 1 of input fields , allows browsers auto-complete fill in information, disables code , not show in 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 show code later down page. not show if browser autocomplete done when entering 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 way can change this, works either way?

per comment duplicate - ideally i'm not looking disable auto fill feature great feature. want code work it.

one quick solution: add event listener input event instead of keyup event. mdn reference page:

the dom input event fired synchronously when value of <input> or <textarea> element changed

so code this:

$(document).ready(function() {   $(".preview").on('input', function() {     $($(this).data('copy')).html($(this).val());   }); });  

i made demo changing names browser detect fields autofill. can see here: http://jsfiddle.net/dc3x6wyu/


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -