Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: help with conditions

  1. #1
    Join Date
    Nov 2004
    Posts
    2

    Default help with conditions

    This is a FANTASTIC script. Very well done!

    But, I cant seem to get conditions working... my form has a yes or no field and if yes is selected, i want the next field to require data, but if no is selected, it is not required. Here is the code I have:

    Code:
    <INPUT TYPE="HIDDEN" NAME="conditions"
    	  VALUE=":##IF#field1=YES#field2~/[a-z.]#If field1 is YES then field2 must contain data.#">
    Would also like to do it so if field1 is YES then field2 AND field3 are required.

    Doesn't seem to be working, maybe I'm just dumb but the instructions in the script seem rather vague. Thanks!

  2. #2
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: help with conditions

    Hi,

    This does what you want:
    Code:
    <input type="hidden" name="conditions"
     value=":##IF#field1~/^YES$/#field2##If field1 is YES then field2 must contain data.#" />
    Would also like to do it so if field1 is YES then field2 AND field3 are required.
    You need two conditions for this:

    Code:
    <input type="hidden" name="conditions"
     value=":##IF#field1~/^YES$/#field2##If field1 is YES then field2 must contain data.#:
     #IF#field1~/^YES$/#field3##If field1 is YES then field3 must contain data.#" />
    Doesn't seem to be working, maybe I'm just dumb but the instructions in the script seem rather vague.
    Conditions are difficult. You really need to be a programmer with a knowledge of regular expressions to successfully create conditions.

    The instructions we've given are sufficient for qualified programmers, but are probably not much use for anyone else.

    We do have plans for a HOW-TO guide to assist non-programmers, but it's a bit like trying to describe how to do a heart transplant (slight exaggeration, but it makes the point).
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Nov 2004
    Posts
    2

    Default Re: help with conditions

    That worked perfectly. Thank you!

  4. #4
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: help with conditions

    Hi,

    Great!

    If you need any other conditions and you can't figure them out, the best thing is to do is just post a request.

    We'll do our best to write and test the condition for you.

    Please try to help us continue to provide free support and free software - the best way to help is to provide a link from your website to ours.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  5. #5
    Join Date
    Nov 2004
    Posts
    10

    Question Re: help with conditions

    Does fmbadhandler.php support conditions? Coz I tried to use conditions on my form.

    Code:
    <input type="hidden" name="conditions" value=":@@IF@ProblemType~Yes@TheProblem@@You have selected Yes for a problem. Please describe your problem.@:@IF@ProblemType~Yes@email@@You have experienced a problem on my site. I need your email to contact you.@" />
    This means, if 'Yes' is selected for 'ProblemType', then 'TheProblem' and 'email' fields must be filled in.

  6. #6
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: help with conditions

    Hi,

    FMBadhandler ignores the hidden fields, like "conditions". Conditions are only processed by FormMail.

    The problem is the syntax of your conditions:

    Code:
    ProblemType~Yes
    must be:

    Code:
    ProblemType~/Yes/
    or, to be more precise:

    Code:
    ProblemType~/^Yes$/
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  7. #7
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: help with conditions

    Hi,

    The "required" feature is mainly used for checking for empty or not empty (as well as some comparisons).

    For complex situations you need conditions.

    The following conditions should do what you requested:

    Code:
     
    <input type="hidden" name="conditions"
     value=":##IF#ProblemType~/^Yes$/#description##If ProblemType is YES then description must be provided.#:
     #IF#ProblemType~/^Yes$/#email##If ProblemType is YES then email must be provided.#" />
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  8. #8
    Join Date
    Nov 2004
    Posts
    10

    Question Re: help with conditions

    Hi Russell.

    You've been of great help, and i'll have to bother you again. I've set up a web Link Submission form, and I wrote a condition to make sure that if the Link Name was Provided, the Link Address must be entered and vice versa.

    Code:
    <input type="hidden" name="conditions" value=":@@IF@LinkName1@Link1@You have entered a Name for the 1st Link. Please enter the Link Address.@" />
    <input type="hidden" name="conditions" value=":@@IF@Link1@LinkName1@You have entered a Link for the 1st Link. Please enter the Link Name.@" />
    Is this a valid condition??

  9. #9
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: help with conditions

    Hi,

    They both look valid, but you can only have one field called "conditions" in your form.

    The easiest way to do multiple conditions, is to name the first one "conditions1", then second one "conditions2", and so on.

    You can also put multiple tests in each conditions field. You simply use your first separator character to delimit them.

    Like this:

    Code:
    <input type="hidden" name="conditions5" value=":@
    	@IF@country ~ /^us$/@
    		  state@@Please enter the state for country 'us'@:
    	@IF@country ~ /^ca$/@
    		  state@@Please enter the state for country 'ca'@" />
    See the ':' after the first condition and before the "@IF" of the second one?

    Notice that you can format with new lines and indentation to make things easier to read.

    The only problem you'll hit with this is ensuring you don't make a value too long. FormMail puts a limit of 1024 characters per field value (but you can change this in formmail.php).
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  10. #10
    Join Date
    Nov 2004
    Posts
    10

    Question Re: help with conditions

    Hi Russell,

    I've tried to use multiple conditions, but it doesn't work! Could you please check it out at http://galen.aspfreeserver.com/LinkSubmission.php, as well as http://galen.aspfreeserver.com/ContactForm.php. I can't seem to figure out what went wrong!!! It's driving me crazy! I did everything that is possibly wrong, and the submission still goes through!!

    As for the contact form, it worked until I added the validate email code you provided in another thread. Please help! Thanks!



    Rgds,

    Galen

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Conditions for a valid email address
    By bwv in forum FormMail Subscription Support
    Replies: 5
    Last Post: 04-Jul-2005, 09:24 PM
  2. Multi-forms and certain conditions
    By Chrisanna in forum FormMail Subscription Support
    Replies: 1
    Last Post: 22-May-2005, 09:32 PM
  3. Conditions: Can we use PHP predefined regex?
    By railer in forum FormMail Subscription Support
    Replies: 2
    Last Post: 14-May-2005, 05:06 PM
  4. Sample Conditions Code
    By railer in forum FormMail Subscription Support
    Replies: 1
    Last Post: 14-May-2005, 05:01 PM
  5. Help with mail_options and conditions
    By wufpack00 in forum FormMail Subscription Support
    Replies: 2
    Last Post: 06-Jul-2004, 01:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •