Home
TeamSite
Limit comma separated values in textarea
Michael_Mc_OFI
Hello all, I have what I believe to be a challenging problem. After a user completes a template entry, they can add metadata to the item. We allow them to enter a comma-separated list of keywords into a textarea.
The problem we have is that the keyword length is limited in the database, lets say to 25 characters. Now, I have a regex to limit the overall length of the textarea:
textarea wrap="virtual" cols="50" rows="3" validation-regex="^[\s\S]{1,1000}$"
but what I need to do is check each individual entry for length. Any ideas on how this might be done (via regex)?
Thanks, in advance, for your responses.
Find more posts tagged with
Comments
JonathonG
How about:
validation-regex="^(.{1,25},)+.{1,25}$"
I'm pretty sure this will do what you want, but others may have other thoughts as well.
jbonifaci
This should only let the user enter 25 characters between each comma:
^([^,]{1,25}(,|$))*$
~Jeff
Michael_Mc_OFI
I'll give each of those a go, and post the results. Again, thanks so much!
JonathonG
Just a couple of brief distinctions. jbonifaci's regex will allow the string to end in a comma, mine won't. Also, mine will allow a user to enter ",," and Jeff's won't. So, which one you use probably depends on your requirements.