Question

$('#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?

Was it helpful?

Solution

try this

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

OTHER TIPS

You may use (this)

replace(/\s/g,'')

\s matches a single white space character, including space, tab, form feed, line feed but don't know what your $(this).text() contains, so not sure about the result.

function __kill(text){return text.replace(/\n\r|\n|\r|\t/g,'');};

\t <<<---like this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top