close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Conditional Validation, Dropdown List Value Equal To 1

Thread began 1/07/2013 12:44 pm by vernon webb | Last modified 1/24/2013 12:47 pm by Jason Byrnes | 2386 views | 20 replies |

vernon webb

Conditional Validation, Dropdown List Value Equal To 1

I want to set up a conditional validation where when the value of a drop-down list (Number of Appointments Set: ) is 1 then I want a text field (Company: ) to be required.

user_times_Insert.php

Not sure how to go about doing this with Validation Toolkit. Anyone have any ideas?

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

this will take a little hand coding in the Server validation interface, but it can be done.

Select required/ not blank for the validation type.

for the server variable, click the lightning bolt icon and select the number of appointments form element.

the code for the server variable will look like this:

php:
((isset($_POST["APPTS"]))?$_POST["APPTS"]:"")




change it to:

php:
(((isset($_POST["APPTS"]) && $_POST["APPTS"] == "1"))?$_POST["apptCompany"]:"NA")



this will validate the apptCompany form element if 1 is selected in the APPTS form element, otherwise it will pass "NA" to the validation to pass the required validation.

Sign in to reply to this post

vernon webb

Not completely following here. I should add this and then a validation to check if the "company" field is black or not?

Sign in to reply to this post

Jason ByrnesWebAssist

no, when you add the required validation for the select list, make the change to the server variable as i suggested, this will check the select list value, and if it is 1, it will validate that the company element is not blank.

Sign in to reply to this post

vernon webb

Looks like you may have misunderstood what I was asking for. The drop down list (APPTS) has values of 0 and 1, when that is selected I would like to requite the text field (apptCompany) to be a required field. I think what you did was you changed the dynamically populated field to equal NA which is not at all what I am trying to do. Everything, as the page is set now works exactly as I want except what I described above which I have added nothing for yet.

Sign in to reply to this post

Jason ByrnesWebAssist

so you want validation to occur if either 0 or 1 are selected?

then change the code to:

php:
(((isset($_POST["APPTS"]) && ($_POST["APPTS"] == "1" || $_POST["APPTS"] == "0")))?$_POST["apptCompany"]:"NA")



the NA value is just there to force it to pass validation of the apptCompany field does not need to be validated.

Sign in to reply to this post

vernon webb

Sorry for the delay in responding I had to table this for a bit but am back at it now.
This is not working as expected.

I have made the changes as you suggested, but for some reason this change causes the APPTS form field to submit to the database as blank and does not require the user to fill out the apptComapny field which is what I am going for.

Also, currently the field "Number of Appointments Set" is being used to populate "Appointment Type" using the Dynamic Dropdown Extension (which is working) so I'm not sure if that is some how interfering.

I want for the user to be required to enter a value in the Company field (apptCompany) if the user selects a 1 from the Number of Appointments Set (APPTS) which already set as a Select required/ not blank for the validation type.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

please send a copy of the page.

Sign in to reply to this post

vernon webb

It's attached.

Attached Files
user_times_Insert.zip
Sign in to reply to this post

Jason ByrnesWebAssist

i dont see any server validations on this page.

it looks like you took the code i gave and added to the Insert Record behavior, this is not what i had suggested.

i had suggested that you add server validations to the page, and using the required validation type, use the code i provided for the server variable

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...