javascript - jQuery input vs textarea on paste different behaviour -


i have been struggling find definite solution problem paste on input.

i have got following regex control on input

var match = str.match(/^[^,]*,[^,]*,.*$/mg); 

you can see example of usage on following demo link. problem when paste content

123, john smith, jack david 321, jackie ronal, david blah 

into input field, whole content single entry whereas in textbox recognizes new line , looking (as can see in demo procided).

now, can give me nice solution problem solved input field great otherwise if have use textarea need find way make textarea borders hidden far understanding there no cross browser solution nicely (hid borders , resize icon in browsers).

here demo

http://jsfiddle.net/tcmcp/3/

any appreciated.

demo

instead of input, can use div contenteditable set true (this technically incorrect, provides support ie). example styles can found in fiddle.

<div contenteditable="true" id="input"></div> 

we can text content using javascript.

$('#input').on('paste', function () {     settimeout(function () {         var str = $('#input').text();         jsprint("pasted", str);         $('#input').text(str);          var match = str.match(/^[^,]*,[^,]*,.*$/mg);                   }, 100); }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -