Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing one text box value in another text box while user type the value to the text box

Is there a way to get the value from one text box and add it to another using jQuery dynamically when user is typing the value to the text box? can someone please explain the method if there is any such thing?

regrds, Rangana

like image 374
Rangana Sampath Avatar asked Dec 07 '22 01:12

Rangana Sampath


1 Answers

You mean something like http://jsfiddle.net/ZLr9N/?

$('#first').keyup(function(){
    $('#second').val(this.value);
});

Its really simple, actually. First we attach a keyup event handler on the first input. This means that whenever somebody types something into the first input, the function inside the keyup() function is called. Then we copy over the value of the first input into the second input, with the val() function. That's it!

like image 158
Yi Jiang Avatar answered Feb 16 '23 00:02

Yi Jiang