How to add new line in text area using Jquery Mulitple Autocomplete when pressing enter? -
i using in textarea instead of input field
https://jqueryui.com/autocomplete/#multiple
my jquery code below
<script> $(function() { var availabletags = [ "headache", "headache time", "increase in morning", "headache effect on vision", "only episodic headache vomiting", "one sided headache" ]; function split( val ) { return val.split( / \s*/ ); } function extractlast( term ) { return split( term ).pop(); } $( ".tags" ) // don't navigate away field on tab when selecting item .bind( "keydown", function( event ) { if ( event.keycode === $.ui.keycode.tab && $( ).autocomplete( "instance" ).menu.active ) { event.preventdefault(); } }) .autocomplete({ minlength: 0, source: function( request, response ) { // delegate autocomplete, extract last term response( $.ui.autocomplete.filter( availabletags, extractlast( request.term ) ) ); }, focus: function() { // prevent value inserted on focus return false; }, select: function( event, ui ) { var terms = split( this.value ); // remove current input terms.pop(); // add selected item terms.push( ui.item.value ); // add placeholder comma-and-space @ end terms.push( "" ); this.value = terms.join( " " ); return false; } }); }); </script>
currently textarea showing http://prntscr.com/7cxvgb , want http://prntscr.com/7cxvvd mean whenever press enter in text area should add new line.
current output http://prntscr.com/7cxweu want in new line when press enter in textarea. in advance.
Comments
Post a Comment