How to assign a text field value to another text field using jquery

I have two text fields, in my opinion,

My requirement is when I enter text in the first text field automatically, this value should be assigned to the second text field when I leave the first text field. using jquery or javascript.

thanks for the help

EDIT:

For some reason, this code does not insert a value into a protected text field.

http://jsfiddle.net/9tEV2/4/ 
+4
source share
4 answers

Capturing the onchange event of the first text field and in the event handler will assign the first value of the text field to the second.

Sort of:

 <input type="text" id="name"/> <input type="text" id="anotherName"/> <script type="text/javascript"> $(function(){ $("#name").change(function(){ $("#anotherName").val($(this).val()); }); }) </script> 
+8
source
 $('#textbox1').blur(function(e) { $('#textbox2').val($(this).val()); }); 
+5
source

Non-jQuery solution:

 A.onblur = function() { B.value = this.value; }; 

Where A and B are links to text field elements.

Live demo: http://jsfiddle.net/simevidas/9tEV2/

+4
source

Hello, Strike>

try

 $('#Text1').keypress(function () { $('#Text2').val($(this).val()); }); 

Hope this is helpful

Do not review this post, I did not read the question correctly

+3
source

Source: https://habr.com/ru/post/1346610/


All Articles