Handle multiple demiliter possibility of texterea
Have an issue handling people using texterea to submit multiple id strings, I have to handle that not make what the user enters as delimiter, I have to pass it to comma delimiter to the back end. Basically I need to treat, ;, newline, returns, space, white space, blank etc to comma. Just wondering if there is an expression I can use.
str = document.mform.txtInput.value
//remove unwanted space,change all delimiler to comma
Thanks in advance.
got it. By using regular expression. return space as demiliter.
return str.replace(/^\s+|\s+|\;+|\,+|\n+|\r$/g," ");
Last edited by jt107; 06-29-2011 at 03:15 PM.
What is the purpose of the FIRST and SECOND \s+ value in the expression?
Originally Posted by jt107
Would only one work just as well?
"these;are,using different-delims".split(/[;,-_ ]/) +""
Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)