Alex Rivera | Logout

Synchonise 2 input fields, can it be done using jQuery?

Asked 2012-01-10T12:39:59.397
17

Can jQuery synchronise or copy the text of one input field to another when input A is modified? For example:

<input id="input_A" type="text" /> ...If I type something here

<input id="input_B" type="text" /> ... It will be copied here

Can jQuery Do this?

Edit
Report

1 Answer

3

During writing, pasting, etc value will be copied. In jQuery < 1.7 instead on use bind.

$( "#input_A" ).on( "paste keyup", function() { 
     $( "#input_B" ).val( $( this ).val() );
});
answered 2012-01-10T12:41:26.277

Your Answer