www.webdeveloper.com
Results 1 to 4 of 4

Thread: Handle multiple demiliter possibility of texterea

  1. #1
    Join Date
    Feb 2010
    Posts
    34

    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

    function handleInput(str)
    {
    //remove unwanted space,change all delimiler to comma


    }

    Please advice.

    Thanks in advance.

  2. #2
    Join Date
    Feb 2010
    Posts
    34

    resolved

    got it. By using regular expression. return space as demiliter.

    function handleInput(str){
    return str.replace(/^\s+|\s+|\;+|\,+|\n+|\r$/g," ");
    }
    Last edited by jt107; 06-29-2011 at 02:15 PM.

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,377

    Question

    Quote Originally Posted by jt107 View Post
    got it. By using regular expression. return space as demiliter.

    function handleInput(str){
    return str.replace(/^\s+|\s+|\;+|\,+|\n+|\r$/g," ");
    }
    What is the purpose of the FIRST and SECOND \s+ value in the expression?
    Would only one work just as well?

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Code:
    alert(
    
      "these;are,using different-delims".split(/[;,-_ ]/) +"" 
    
    )

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles