I have two form inputs that I need have matching field content. Meaning if I enter text in one field it is the exact same on the other field (they are in separate forms).
I thought I could use .bind() to do it but my script would not allow my text to bind to another input.
var inp = $("#text1");
if ("onpropertychange" in inp)
inp.attachEvent($.proxy(function () {
if (event.propertyName == "value")
$("div").text(this.value);
}, inp));
else
inp.addEventListener("input", function () {
$("#text2").text(this.value);
}, false);
<input type="text" id="text1" />
<input type="text" id="text2" />
change keyup
to change
if you don`t want to edit it letter by letter; jsfiddle there
var $inputs = $('#input1, #input2');
$inputs.keyup(function(){
$inputs.val($(this).val());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With