Displaying one text field in another text field when the user enters a value in the text field

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

regrds, rangana

+3
source share
4 answers

Do you mean something like http://jsfiddle.net/ZLr9N/ ?

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

. keyup input. , , - - input, keyup(). input input val(). !

+11
$('#textbox1').keypress(function(event) {
    $('#textbox2').val($('#textbox1').val() + String.fromCharCode(event.keyCode));
}); 

, textbox2 textbox1.

.. keyup, , . , "" . , , keyup, keypress , keyup.

+2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
    <title><!-- Insert your title here --></title>
<script type="text/javascript"
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {

    $('#from').keyup(function(event) {
      $('#to').text($('#from').val());
    });

  });
</script>
</head>
<body>
<textarea id="from" rows=10 cols=10></textarea>
<textarea id="to" rows=10 cols=10></textarea>
</body>
</html>
+1
source
$(document).ready(function(){
    $("#textbox1").blur(function(){$('#textbox2').val($('#textbox1').val()});
}

The action will be performed when the text field is eroded.

0
source

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


All Articles