Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi all
 
When i am writing something inside a multi lined textbox and press tab key ,it goes to the next control but i want to move 4 character not to other control.
 
Please help me to do this
 
I searched in Google and got 'AcceptsTab' property in Windows Application for textbox,which will enable and diaable tabbing inside the textbox.
 
but didn't get such property in web application..
 
How to implement the in web application (using javascript or server side).
(I want to implement this type of feature in a textbox not all)
 

Please help
Thanks in advance
Posted 16-Sep-12 20:46pm
Mac123341.1K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this
function bindTabbing(event)
{
    if (event.which || event.keyCode)
    {
        // 9 indicates TAB key.
        if ((event.which == 9) || (event.keyCode == 9))
        {
            var subject = document.getElementById(txtProgramEditor); // Get the Editor textarea control.
            if (event.srcElement == subject) // If tab is pressed in the textarea then do the action.
            {
                // Creates a range and adds the Tab equivalent character in the text range.
                subject.selection = document.selection.createRange();
                subject.selection.text = String.fromCharCode(9);
                event.returnValue = false;
            }
 
            if (subject.selectionStart || subject.selectionStart == '0')
            {
                var str = subject.value;
                var startIndex = subject.selectionStart;
                subject.value = str.substring(0, startIndex) + '    ' + str.substring(startIndex, str.length);
                subject.focus();
                subject.selectionEnd = startIndex + 4;
                return false;
            }
        }
    }
    else
    {
        return true;
    }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this..
 
$('#textboxid').live('keydown', function(e) {
  var keyCode = e.keyCode || e.which;
var s=$('#textboxid').val();
  if (keyCode == 9) {
s=s+"    ";
    e.preventDefault();
    $('#textboxid').val(s);
  }
});
  Permalink  
Comments
MAC123456 at 17-Sep-12 3:24am
   
Sorry its not working..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,745
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,599
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100