Formbuilder validate a textfield

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
janvl
Power Poster
Power Poster
Posts: 947
Joined: Wed Aug 13, 2008 10:57 am

Formbuilder validate a textfield

Post by janvl »

Hi,

i have managed to use a validation with a number through the regex like /^(27)/ for number 27.

Now i am looking to find how i validate a text-input with a word, i tried /^(dog)/ for the word dog but that does not work.

I can find lots of regex-tests but does not seem to fit my wish, do i need javascript here?
and when how do i enter that in CMSMS? Does anyone have an example please?

Kind regards,
Jan
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1629
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Formbuilder validate a textfield

Post by DIGI3 »

It's a perl style regex according to the docs, so for dog (case insensitive) you'd just do:

Code: Select all

/dog/i
See https://perldoc.perl.org/perlre
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Formbuilder validate a textfield

Post by velden »

Additionally I think you need to add a ^ and $ to check for the whole string, not a substring. E.g. dog vs dogma vs bulldog

Code: Select all

/^dog$/i
janvl
Power Poster
Power Poster
Posts: 947
Joined: Wed Aug 13, 2008 10:57 am

Re: Formbuilder validate a textfield [SOLVED]

Post by janvl »

Thanks a lot!

i have build this into the form and it works.

Do not laugh, i forgot to mark that the regex must be used . .

Since there is a real explosion of spamming through contact-forms i need to build validation in those forms.

Regards,
Jan
Post Reply

Return to “Modules/Add-Ons”