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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -