Search code examples
javascriptspacescarriage-return

javascript whats worse than a carriage return?


$('#pass').focusout(function(){
    alert(($(this).text().replace(/\n\r|\n/g,'')).length);
    if(($(this).text().replace(/\n\r|\n/g,''))===''){alert('please be true');$('#water').text('enter password');}
    });

I'm left with a length of 3 which doesn't show up if I do:

alert('_'+($(this).text().replace(/\n\r|\n/g,''))+'_');

i see

alert(__); 

even though the length is 3

these are some kind of tab spaces I think. how the hell can I remove them?


Solution

  • try this

    someText.replace(/(\r\n|\n|\r)/gm,"");