JavaScript Insert Tabs into Textarea; Insert Tabs Into Input; Javascript Tab Indent

How to insert tabs and auto-indent using jQuery.
<textarea cols="50" id="mytextarea" rows="15"></textarea>
Case 13 is the indenting.
                var start=this.selectionStart,val=$(this).val();
                    case 9: /* tab */
                        return false;
                    case 13: /* enter */
                        var match=val.substring(0,start).match(/(^|n)([ t]*)([^n]*)$/);
                            var spaces=match[2],length=spaces.length+1;
                            return false;
                return true;
This post is available on GitHub.
Posted .

1 comment

  1. anonymous

    thanks for this :D

Leave a Reply