CTRL Z Issue

There is an issue in Firefox with textareas in Ctrl+z adding a /n

by dwaddell

HTML

For this example you need to install Firebug to see in the console.log outputs on the Console Tab.
<br><br>
1. Open the Console tab and notice that "9 Delete Me" is the first thing that is outputted.<br>
2. Highlight the Delete Me text and hit the delete key.<br>
3. Tab out and you should see "0" on the Console tab.<br>
4. Return to the text area and and hit Ctrl+z to restore the "Delete Me" text.<br>
5. Tab out and you will notice that the Console tab will have "10 Delete Me" <br>
<br>
If you want to go further with this you can put a break point on the Script tab in the the function fnTest and you will notice that sValue will be "Delete Me/n" after hitting Ctrl+z.
<br>
<br>

<textarea id="ctrlztest" name="ctrlztest">

JavaScript

var $textarea;

$.valHooks.textarea = {
    get: function( elem ) {
        return elem.value.replace( /\r?\n/g, "\r\n" );
    }
};

$textarea= $('textarea#ctrlztest');

$textarea.val("Delete Me");

console.log( $textarea.val().length + ' ' + $textarea.val() );


function fnTest ()
{
    var sValue;
    sValue = $textarea.val();        
    
    console.log( sValue.length + ' ' + sValue );
}

$textarea.change(fnTest);