Using jQuery validation plugin but it has no CSV validation. I have made an additional validation for this but can\'t get the RegEx right.
Here is what I have:
Maybe I'm not totally understanding what you need, but it seems like you could capture all the values with this regex:
/([^,]+),?/
This will allow spaces and special characters in the values, I'm not sure if you want that or not, since your attempt seemed to be trying to only allow word characters.
If you are just trying to check whether they entered something valid or not though, I'm not sure what you would want to consider "invalid". It seems to me that just about anything would be valid. If it doesn't have any commas, it's a single value. If it does, it's multiple values. Maybe if you give some more detail about what data you're expecting I can write a better validating expression.
Building on Chad's example, just switch [^,]
to \w
if you want only word characters. If you actually want just letters and digits, you'll need something like [a-z0-9]
as \w
includes the underscore character.
Based on your comment, see if
/^([a-z0-9])+(,[a-z0-9]+)*$/
does the trick.