Search code examples
jquerycharacter-limit

jQuery character count, separating into two text boxes on limit


I am working on a page that accepts entry into a single textarea, then splits the contained text across two output textareas in realtime should it reach a certain character limit (the first with 0 - x characters, the second with x - end). I have the copying process working, but am at a loss on how to approach the division and have the first textbox stop accepting input while continuing real-time entry on the second one.


Solution

  • You could move the cursor between textboxes by using.

    $('newTextBox').focus();
    

    For the charater limit, use this.

    <textarea maxlength="50">
    
    </textarea> 
    

    Note that it doesn't work on Internet Explorer 9 and earlier versions, or in Opera.