The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Validating via PHP if a text field is blank - 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: Validating via PHP if a text field is blank (/showthread.php?tid=1827) |
Validating via PHP if a text field is blank - michatmaster7 - Dec 17th, 2011 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? RE: Validating via PHP if a text field is blank - michatmaster7 - Dec 30th, 2011 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. RE: Validating via PHP if a text field is blank - Ben - Jan 2nd, 2012 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 RE: Validating via PHP if a text field is blank - michatmaster7 - Jan 11th, 2012 That works, but not for checkboxes that have only one option, see my other thread here: http://forums.formtools.org/showthread.php?tid=1847 |