The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Pulldown to trigger Text field - 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: Pulldown to trigger Text field (/showthread.php?tid=2694)



Pulldown to trigger Text field - MHarrison - Sep 22nd, 2013

Hi guys,

Hope you can enlighten me. I have a Pulldown field with 6 values, "0" to "5", with an adjacent Text field for comments. I need to require the comment field be filled out only when the value of the Pulldown is 0, 1, or 2. This is what I've come up with so far:

Code:
rules.push("required,element_9,Please select an Sportsmanship Rating.");
    rules.push("if:element_9=0,required,element_9B,Please enter an Sportsmanship Comment.");
    rules.push("if:element_9=1,required,element_9B,Please enter an Sportsmanship Comment.");
    rules.push("if:element_9=2,required,element_9B,Please enter an Sportsmanship Comment.");

This is the first instance of 20 such instances on the form, which has worked with all fields simply "required." With this code on the form, the error reporting gets truncated to an error that is always and only about the element_10B field regardless of how the form is filled out.

I started with this example code as a template:

Code:
[if:FIELDNAME=VALUE,]REQUIREMENT,fieldname[,fieldname2[,fieldname3,date_flag]],error message"

but something seems to be missing. I thought I would be validating based on the "range=X-Y" requirement, but I don't see where it belongs in the code. Could you point me in the right direction?

Much appreciated,

Mark Harrison



RE: Pulldown to trigger Text field - MHarrison - Sep 23rd, 2013

Hi folks,

Making some progress, but have run into unexpected behavior. As stated before, choosing "0" "1" or "2" should then require the adjacent comment field to be required. I tried setting "range=0-2" in the following code and the error message was triggered on 3, 4, or 5. So I swapped the range to get the desired behavior. Looks like this:

Code:
    rules.push("required,element_9,Please select an Sportsmanship Rating.");
    rules.push("range=3-5,element_9,Please enter a comment in the next field.");

Easy enough, but possibly highlights a bug in this range validation function, or am I missing something?

Moving on, I then tried to add this line:

Code:
    rules.push("if:range=3-5,element_9,required,element_9B,Please enter an Sportsmanship Comment.");

which breaks the form and prints "process.php" to the browser window for any value, 0-5. Can anyone help me out with this problem?

Much appreciated,

Mark Harrison


RE: Pulldown to trigger Text field - MHarrison - Sep 23rd, 2013

Hi folks,

Now it appears my original code was correct as it now works. Go figure.

Code:
    rules.push("required,element_9,Please select an Sportsmanship Rating.");
    rules.push("if:element_9=0,required,element_9B,Please enter an Sportsmanship Comment.");
    rules.push("if:element_9=1,required,element_9B,Please enter an Sportsmanship Comment.");
    rules.push("if:element_9=2,required,element_9B,Please enter an Sportsmanship Comment.");

Thanks for the sounding board.

Regards,

Mark Harrison