Jun
30
2014
30
2014
Allow Tab in Textarea
If you’re a programmer, then you know exactly how irritating it can be to have a big blank textarea that you just happen to leave if you hit the tab key. Not anymore! var textareas = document.getElementsByTagName(‘textarea’); var count = textareas.length; for(i=0;i<count;i++){ textareas[i].onkeydown = function(e){ if(e.keyCode==9 || event.which==9){ e.preventDefault(); var s = this.selectionStart; this.value = this.value.substring(0,this.selectionStart) + "\t" + this.value.substring(this.selectionEnd); this.selectionEnd = s+1; } } }
Recent Snippets
- htaccess : Only allow access to specific wordpress upload types if logged in
- MySQL : Query WordPress Database for Invalid Media Filenames
- PHP : Get Actual IP Address with PHP
- JavaScript : Allow Tab in Textarea
- PHP : Clean sanitized database contents on output
- htaccess : Force www. prefix in URIs
- PHP : Force File Download with Correct Content Type
- Wordpress : Disable upgrade notification