PDA

View Full Version : Conditional Validation: Both cannot be blank


yogastudents362523
03-03-2010, 11:25 AM
I want Validation Toolkit to insist that I receive either a cell phone number or a land number from my form. One of ['cellphone'] OR ['contactphone'] is required, but both can be provided if desired.

Suppose my error message is "NO". What coding must surround "NO" so Validation Toolkit does what I want and shows "NO" if both phone number fields on my form are left blank?

Please keep this very very simple! I am learning fast ... but I am obviously still a newbie. I've tried experimenting with:
!isset($_POST['contactphone']?!$_POST['cellphone']:"NO" but it's not working out. Either I have that wrong, or I am inserting it in the wrong place.

Thanks.


Thanks.

yogastudents362523
03-03-2010, 12:19 PM
I want Validation Toolkit to insist that I receive either a cell phone number or a land number from my form. One of ['cellphone'] OR ['contactphone'] is required, but both can be provided if desired.

Suppose my error message is "NO". What coding must surround "NO" so Validation Toolkit does what I want and shows "NO" if both phone number fields on my form are left blank?

Please keep this very very simple! I am learning fast ... but I am obviously still a newbie. I've tried experimenting with:
!isset($_POST['contactphone']?!$_POST['cellphone']:"NO" but it's not working out. Either I have that wrong, or I am inserting it in the wrong place.

Thanks.


Thanks.

OK. I think I solved my own problem.
I will create a third, hidden field.
I will then arrange for it to be filled, conditinally, with either one or the other of my two phone fields.

I will then validate that third field. It will be required, and may not be blank. I believe that will work.
Thanks.

Jimmy Wu
03-03-2010, 01:52 PM
That sounds like it will work for this purpose. Make sure to put the code that populates the hidden field before the code that validates the hidden field.