Results 1 to 2 of 2

Thread: split string and validate

  1. #1
    Join Date
    Feb 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default split string and validate

    I have a survey question that is a drag & drop that sorts from 1 list into 3 choice lists [Most important, Somewhat Important, Not Important]

    The data is writing correctly. It starts out as: A,B,C,D,E,F,G,H,I,J

    As you move the list items, it writes like this: C,E,I|F,H,A|J,D|G,B So it has pipe-separated the three destination lists.

    When I did this before, I was only moving the options to one destination list and I was able to validate that using:

    var str = document.forms[0].M9_p.value;
    var res = str.split(",");
    if(res.length<11) {
    strErrorMessage="Please drag and drop all items";
    }

    Now my problem is that I don’t know how to split the string and count only the remaining items to the left of the 1st pipe only.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Avoiding duplication - for reference - posted elsewhere http://www.webdeveloper.com/forum/sh...and-validating
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Append string to the end of string via a loop
    By l_kris06 in forum JavaScript
    Replies: 1
    Last Post: 06-24-2009, 02:59 PM
  2. split a string by 3 condition .......pls help
    By pankaj.ghadge in forum JavaScript
    Replies: 1
    Last Post: 12-23-2008, 04:03 PM
  3. how to split the string in 2 parts
    By pankaj.ghadge in forum PHP
    Replies: 3
    Last Post: 11-13-2008, 06:54 PM
  4. split a string
    By mhodgson in forum JavaScript
    Replies: 3
    Last Post: 05-02-2007, 11:44 AM
  5. Need help how to validate string is valid hostname
    By vince144 in forum JavaScript
    Replies: 7
    Last Post: 09-19-2006, 07:06 PM

Bookmarks

Posting Permissions

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