Page 1 of 1

formbuilder form validation

Posted: Mon Aug 24, 2015 8:57 pm
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

Re: formbuilder form validation

Posted: Mon Aug 24, 2015 9:37 pm
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

Re: formbuilder form validation

Posted: Thu Aug 27, 2015 12:41 pm
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