The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use validation only if ...

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 ?


Hi Alex,

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

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.

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
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

Forum Jump:

Users browsing this thread: 1 Guest(s)