When I paste the following into the text area, when onblur it's supposed to tidy up the text pasted removing certain words, tab spaces and tidying up by placing each value separated by the tabs spaces into it's own line. But it always leaves a blank empty line at the very first line:
Note: I can't seem to emulate tab spaces in html so you'll have to manually type the following in notepad to properly replicate my problem: where %%% replace with tab space in notepad then select-all and copy/paste into my js fiddle example textarea
Customer account %%% Name %%% Telephone %%% Street name %%% City %%% postcode%%% 1234LA3 %%% KCI ASDFGHJ %%% 1234567890 %%% 10 EXAMPLE ST %%% EXAMPLE CITY %%% 1234
when you onblur It ends up looking like this:
1234LA3 KCI ASDFGHJ 1234567890 10 EXAMPLE ST EXAMPLE CITY 1234
notice blank empty space above '1234LA3'.
I've already tried adding \n\r in my .replace() method but still doesn't seem to filter out this empty line.
any kind of help will be greatly appreciated. thank you!
A regex would work like so, if you were to go that way:
Yes? Someone sanity check this for me?
Seems to do the trick.
DEMO
Also, you can emulate tab characters in html with
	
, not to mention that you don't need to prefix javascript in events withjavascript:
.Or just add \t after the first replace:
The problem arises, because you have a tab after the last title.