javascript - String input automatically entered into readonly field -


is possible copy input entered field uneditable field javascript? example have 2 name fields, first field must enter name, once entered name automatically copied in second text field uneditable. have done bit of searching around can't seem find of use specific situation , i'm quite knew javascript sort of or nudge in right direction great.

just use keyup listener of input:

<input type="text" id="input1" /> <input type="text" id="input2" readonly='readonly' />  var $input2 = document.getelementbyid('input2'); var $input1 = document.getelementbyid('input1'); $input1.addeventlistener('keyup', function() {   $input2.value = $input1.value; }); 

here's example: fiddle


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -