3

I want to make an editor for my webpage so I can easily edit my pages. I'm using a textarea for the editor. The textarea is inside of a form.

Therefore, if I use tab to indent, the cursor jumps to the Submit button.

I found some methods to set the tabindex to -1, but this won't help.

Is there some way to disable the tab function?

<form method='GET' action='pages/save.php'>
 <textarea id='textbox' class='form-control' name='textarea' rows='20' cols='80'></textarea><br />
  <input id='safebutton' type='submit' value='Save' />
 </form>
yivi
  • 42,438
  • 18
  • 116
  • 138
Nicolo Lüscher
  • 595
  • 7
  • 22

1 Answers1

2

Go to through this Fiddle

You will get which you want.

HTML :

<textarea placeholder='Enter text Here....'>

</textarea>

css :

textarea{

height:250px;
  width:100%;
}

JS :

$("textarea").keydown(function(e) {


 if(e.keyCode === 9) { 
        var start = this.selectionStart;
            end = this.selectionEnd;

        var $this = $(this);

        $this.val($this.val().substring(0, start)
                    + "\t"
                    + $this.val().substring(end));

        this.selectionStart = this.selectionEnd = start + 1;

        return false;
    }
});
Maulik
  • 765
  • 3
  • 14