-1

I have a text area

<textarea id="realAreaWhereUserTypes"></textarea>

And i have a hidden input field liek follow.

<input id="hiddenUserInput" />

The textArea contains the value like follows :

This is my friend @bingo_mingo and this is my another friend @lingo_tingo

The hidden field fields contains the same text but in different format.

This is my friend @a142f2f0-1eda-11e3-ad5f-3c970e02b4ec:bingo_mingo and this is my another friend @a143edr0-1eda-11e3-ad5f-3c970e02b4ec:lingo_tingo

I want these two fields to synchronize. And whenever i delete something from the real text Area the hidden should get updated.Also if i start deleting the @admin_admin in the main text the hidden text should update accordingly.

Is there any jquery plugin avaiable avaiable for this.

Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212

3 Answers3

1

I haven't used one. Have you looked for any? This may be one: http://github.com/ain/jquery-fieldsync Also, this question is a duplicate: Synchonise 2 input fields, can it be done using jQuery?

Community
  • 1
  • 1
tjons
  • 4,749
  • 5
  • 28
  • 36
1

Use .clone() from Jquery. It's easy http://api.jquery.com/clone/

daniel__
  • 11,633
  • 15
  • 64
  • 91
JK84
  • 325
  • 1
  • 2
  • 13
0

You can create a listener that will update the hidden field with the updated text whenever it is changed.

$("#realAreaWhereUserTypes").bind("keyup paste", function() {
    var newStr = formatName($(this).val());
    $("#hiddenUserInput").val(newStr);
}); 

function formatName(str){
   // Do whatever change you need here.
}
ajon
  • 7,868
  • 11
  • 48
  • 86