FORUMS


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
Pulldown to trigger Text field
#1
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
Reply
#2
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
Reply
#3
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)