The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Validate two fields... - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8)
+--- Forum: Form Validation: JS + PHP (https://forums.formtools.org/forumdisplay.php?fid=18)
+--- Thread: Validate two fields... (/showthread.php?tid=286)



Validate two fields... - checog0 - Sep 18th, 2009

Hi, I want to know if its possible to validate two fields,

I have a field "city" type select and field "section" type text,

Now, each city (I have about 100) have about 8 sections, but I don't wanna show the sections for each city, I want validate the sections depends of the city selected, if the section typed doesn't correspond to city sections show and error in the section filed.

its possible?


RE: Validate two fields... - Ben - Sep 19th, 2009

Hi Checog,

Sure, no problem! For the PHP validation, that's no problem - you can just test for the city value, then run the appropriate validation rules. For JS, you need to use the following rule format:

Code:
rules.push("if:city=Vancouver,required,field1,Please enter field 1.");
rules.push("if:city=Seattle,required,field2,Please enter field 2.");

In that example, field1 will only be validated (checked it's been filled in) if and only if the user has selected Vancouver in the city field.

Hope this helps!

- Ben


RE: Validate two fields... - checog0 - Sep 21st, 2009

(Sep 19th, 2009, 1:16 PM)Ben Wrote: Hi Checog,

Sure, no problem! For the PHP validation, that's no problem - you can just test for the city value, then run the appropriate validation rules. For JS, you need to use the following rule format:

Code:
rules.push("if:city=Vancouver,required,field1,Please enter field 1.");
rules.push("if:city=Seattle,required,field2,Please enter field 2.");

In that example, field1 will only be validated (checked it's been filled in) if and only if the user has selected Vancouver in the city field.

Hope this helps!

- Ben

For example, how to validate:

If I have a field City and field regcode, city field its type select and regcode its text type, user have to enter this value manually

In regcode field, If city=Vancouver and regcode= 1125 or 1518 or 2115 or 3425 its valid, any other value its incorrect

Each city have about four or nine valid regcodes, I want to validate that each user insert a valid code for the city that has been select.


RE: Validate two fields... - checog0 - Sep 21st, 2009

finally it works, I did use:

rules.push("if:city[]=Vancouver,reg_exp,regcode,^\s*(1125|1126|1127)\s*$, wrong regcode city");


RE: Validate two fields... - Ben - Sep 26th, 2009

Nice!