I\'m trying to figure out how to copy a users text input in one form field to another. Specifically, when someone fills in their email address in the contact form, it will b
You said you want it in real time. I assume that means while the user is typing, the value should be replicated for each keystroke.
If that's right, try this:
var mail = document.getElementById("mail");
$("#email").keyup(function() {
mail.value = this.value;
});
Or if you want more jQuery:
var $mail = $("#mail");
$("#email").keyup(function() {
$mail.val( this.value );
});
This will update for each keyup
event.
I'd probably add a redundant blur
event in case there's an autocomplete in the field.
$("#email").blur(function() {
$mail.val( this.value );
});