Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autofill input field with value of another input field

Tags:

jquery

input

I'm going crazy about this. I found a plain JavaScript solution for my problem:

<script type="text/javascript" language="JavaScript" src=""> 

s1 = new String(catwebformform43575.EmailAddress.value)

function changeVal() {

    document.catwebformform43575.Username.value = catwebformform43575.EmailAddress.value;

}

</script>

<BR>
<BR>
<form name="catwebformform43575">
 <input type="text"id="EmailAddress" name="EmailAddress" value="" onkeyup = "changeVal()">
 <input type="text" id="Username" name="Username" value="">

but I need a jQuery solution...Can anybody help?

like image 547
nw5280 Avatar asked Feb 08 '11 12:02

nw5280


1 Answers

$("#EmailAddress").keyup(function(){
    $("#Username").val(this.value);
});

See a working demo

like image 87
rahul Avatar answered Sep 27 '22 23:09

rahul