Required drop down field

Contributor ,
Dec 12, 2019 Dec 12, 2019

Copy link to clipboard

Copied

I could use some help with something I can't find on the forums.  I have a fillable form with a drop down field named 'EmployeeName' and a text field named 'WorkDate' which is formatted to enter a custom date.  I would like to ensure the user selects their name from the drop down list BEFORE they fill out the date in the text field.  Is this even possible?  or have some sort of alert message that pops up if they try entering the date before selecting their name?  Thanks!!  

TOPICS
Acrobat SDK and JavaScript

Views

292

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Most Valuable Participant , Dec 12, 2019 Dec 12, 2019
Sure, that's possible. You can use this code as the custom validation script of the WorkDate field: if (this.getField("EmployeeName").valueAsString==this.getField("EmployeeName").defaultValue) { app.alert("Error! You must first select your name.") event.rc = false; }

Likes

Translate

Translate
Contributor , Dec 13, 2019 Dec 13, 2019
That's exactly what I needed!  Thank you so much!!

Likes

Translate

Translate
Most Valuable Participant ,
Dec 12, 2019 Dec 12, 2019

Copy link to clipboard

Copied

Sure, that's possible. You can use this code as the custom validation script of the WorkDate field:

if (this.getField("EmployeeName").valueAsString==this.getField("EmployeeName").defaultValue) {
	app.alert("Error! You must first select your name.")
	event.rc = false;
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 13, 2019 Dec 13, 2019

Copy link to clipboard

Copied

That's exactly what I needed!  Thank you so much!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Hi Try, I'm hoping you can help me.  I added the script you provided me in the Work Date text field but it's causing an issue with the Clear Form button.  When I clear the form everything clears except the work date and the alert message pops up.  I have to add the Employee Name again, delete the date and then I can clear it.  Is there a way of resolving this?  I don't need the fields to be required, I just need to remind the user to add their name first.  Thank you!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

That's the problem with using a Validation script. You can add a command to your Reset button to make the field not-required.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

I'm looking at the button properties, how do add a command to make the field not required?  Sorry, I'm a little confused 😞

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Well, on the reset button I removed the checkbox to reset the work date field so at least the alert doesn't pop up but the work date field doesn't reset.  I'm searching for what you suggested but I can't find anything.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

You need to do it with a script, like this:

this.getField("WorkDate").required = false;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Ugh, I'm doing something wrong 😞 I think what you mean is to put this.getField("WorkDate").required = false; in Actions Run A Script in button properties, but that's not working.  I'm sorry, I feel bad 😞

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Please be more specific. What does "it's not working" means, exactly?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

I still get the alert pop up to enter employee name first when I hit the clear form button

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

traceyc28668387_0-1594849223277.png

This pops up when I hit Clear Form

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

This has nothing to do with the field being required or not...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Oh, sorry.  I wasn't sure what you meant earlier.  I don't know why the alert is popping up when I click on clear form 😞

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Because that triggers the validation event...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

LATEST

I'm sorry I confused you.  I shouldn't have said the fields don't need to be required.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines