formbuilder form validation

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
cborg

formbuilder form validation

Post by cborg »

Hi guys,

i am trying to use the formvalidation in formbuilder but I do something wrong.

cmsms 1.11.11
Formbuilder 0.8.1.1
PHP 5.4.35

textfield (fld_31)
fieldvalidation - numeric

UDT

Code: Select all

if ($fld_31 = 12) $errors=false;
if ($errors = true) {
  return Array(false, "<strong>Nicht die richtige Wert eingegeben</strong>");
} else {return Array(true,'');}
I would be very gratefull if someone could tell me what I am doing wrong for it never validates. I just want to check whether the number 12 is entered in the field.

Love,
Candy
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: formbuilder form validation

Post by Jo Morg »

In your code you are assigning values to the variables instead of testing for equality:

Code: Select all

if ($fld_31 = 12) $errors=false;
should be

Code: Select all

if ($fld_31 == 12) $errors=false;
and accordingly

Code: Select all

if ($errors = true)
should be

Code: Select all

if ($errors == true)
But I would try this:

Code: Select all

if ($fld_31 != 12) {
  return Array(false, "<strong>Nicht die richtige Wert eingegeben</strong>");
} else {return Array(true,'');}
*Note: I didn't test the code, I just spotted these errors... it may very well still fail to work
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
cborg

Re: formbuilder form validation

Post by cborg »

Thanks Jo Morg

If I use regular expression, found that in another thread, it works.
[12] as validation regex.

But I like to use the UDT for more extensive checks.

I will try this and notify.

Love
Candy
Locked

Return to “Modules/Add-Ons”