开发者

How to assign Textbox value to the other textbox using jquery

I have two textboxes in my view,

My requirement is when I enter some text in the first textbox automatically that value should be assigned to second text box when I leave first textbox. using jquery or javascript.

thanks for your help

EDIT:

For Some reason this code is not inserting the value into seconed tex开发者_如何转开发tbox.

http://jsfiddle.net/9tEV2/4/


Capture the onchange event of the first textbox and in the event handler assign the first textbox value to second one.

Something like:

<input type="text" id="name"/>
<input type="text" id="anotherName"/>

<script type="text/javascript">
$(function(){
  $("#name").change(function(){
   $("#anotherName").val($(this).val());
  });
})
</script>


$('#textbox1').blur(function(e) {

    $('#textbox2').val($(this).val());

});


Non-jQuery solution:

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

Where A and B are references to the text-box elements.

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


Hi

try with

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

I hope it's helpful

Do not consider this post, I didn't read correctly the question


<script type="text/javascript">
    $(function () {
        $("#txt1").change(function () {

           $("#text2").val($(this).val());// For Single textBox
            $("#filltext").find("input:text").val($(this).val()) // Fill textbox1 value to multiple textboxes present in a single div(filltext is Division ID)
        });
    })
</script>`
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜