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
Validating via PHP if a text field is blank
#1
I admit, this sounds dumb, but... using this bit of code:

Quote:if:FIELDNAME=VALUE,

How can I require another field to be required, IF a specific text field is left blank?

Is there a "value" for blank?
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#2
I'm going to assume from the silence and lack of views to this thread that such an answer doesn't already exist. Sigh.

Here's what I have:

Name: {text field}
School: {text field}
Sponsor: {checkbox}

I need the Name and School field to both be required, but ONLY if the Sponsor field is left unchecked. Likewise, I need the Sponsor field to be required, but ONLY if the Name and School fields are left blank.

Ideas? Comments? Suggestions? You can tell me to stop thinking so hard, that would be ok, too..lol.

Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#3
Hi Michatmaster,

Sorry for not getting back to you sooner! Actually yes, you can detect for the field being empty just by entering no VALUE. e.g.

Code:
rules.push("if:FIELDNAME=,required,SECONDFIELD,your error here.");

The syntax looks a bit weird, but it should work fine.

Let me know if you don't have any luck with it!

- Ben
Reply
#4
That works, but not for checkboxes that have only one option, see my other thread here: http://forums.formtools.org/showthread.php?tid=1847

Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)