I have two textboxes one is type='text'
and second is type='hidden
'.I want to when something is typed in first textbox to set same value in the second automatically.
I tried something with .change()
, but it was not good.
In short: I want same value on both textboxes at sometime [real time]
Do you have some idea how to do it?
I have two textboxes one is type='text'
and second is type='hidden
'.I want to when something is typed in first textbox to set same value in the second automatically.
I tried something with .change()
, but it was not good.
In short: I want same value on both textboxes at sometime [real time]
Do you have some idea how to do it?
Share Improve this question edited Aug 25, 2014 at 11:01 Oomph Fortuity 6,19812 gold badges49 silver badges91 bronze badges asked Aug 25, 2014 at 10:56 user3809590user3809590 1851 gold badge3 silver badges13 bronze badges 1-
along with
change
listen tokeyup
,input
,paste
etc – Arun P Johny Commented Aug 25, 2014 at 11:02
8 Answers
Reset to default 4Use keyup
as below
$("#txt1").on('keyup',function(){
$("#txt2").val($(this).val())
});
Just change event for keyup
event,
$("#txt1").keyup(function()
{
$("#txt2").val($(this).val())
});
Try this:
$("#txt1").keyup(function(){
$("#txt2").val($(this).val())
});
You can also use keyup()
of JQuery. It is called when user releases a key on the keyboard.
$("#txtbox").keyup(function(){
$("#hiddentextbox").val($(this).val())
});
You can use .keydown():
$("#txt").on("keydown", function(){
$("#hid").val($(this).val());
});
fiddle
Use the input event:
$('#txt1').on('input',function() {
$('txt2').val( this.value );
});
HTML code
input type = "text" size = "40" id = "inputText">
<input type = "text" size = "40" id = "outputText" value = "" readonly>
jQuery script
$(document).ready(function(){
$('#inputText').keyup(function(){
$('#outputText').val($(this).val());
});
});
Hope this would be helpful to you. Thank you for the useful question.
use .blur
as :-
$("#txt1").blur(function(){
$("#txt2").val($(this).val())
});
OR
$("#txt1").keyup(function(){
$("#txt2").val($(this).val())
});