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
use validation only if ... - 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: use validation only if ... (/showthread.php?tid=231)



use validation only if ... - Alexis - Aug 6th, 2009

Hello

what i would love to do is to validate the form only if the user has selected "validate the form"

i'd like to have a select with 2 options
Validate the form
Save data without validating.

if the user selects save w/o validating it just sends the form
if he selects validate the form it calls the validate script

any ideas on how to do this ?

thanks

alex


RE: use validation only if ... - Ben - Aug 6th, 2009

Hi Alex,

Sure! The simplest way to do it would be to just add a pair of radio buttons like so:

Code:
Validate form? (x) Yes ( ) no

Then add an "if:" clause to the beginning of all your JS validation rules that tell it to only run that validation if the validate field == "yes", (I'm assuming the name attribute of the radio buttons is "validate"), e.g.

Code:
var rules = [];
rules.push("if:validate=yes,required,field1,Please fill in field 1.");
rules.push("if:validate=yes,required,field2,Please fill in field 2.");
...

Then, on the backend, you could do something similar: just check that the incoming $_POST["validate"] == "yes" and then run the rules.

Hope this helps a bit. Smile

- Ben


RE: use validation only if ... - Alexis - Aug 7th, 2009

oh my god!
i was googling until 2am yesterday to find how to include the js with ajax or something complicated

your solution works perfectly
thanks for your scripts, they're just great