• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Required drop down field

Engaged ,
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

964

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

Community Expert , 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;
}

Votes

Translate

Translate
Engaged , Dec 13, 2019 Dec 13, 2019

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

Votes

Translate

Translate
Community Expert ,
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;
}

Votes

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
Engaged ,
Dec 13, 2019 Dec 13, 2019

Copy link to clipboard

Copied

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

Votes

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
Engaged ,
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!!

Votes

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
Community Expert ,
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.

Votes

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
Engaged ,
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 😞

Votes

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
Engaged ,
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.

Votes

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
Community Expert ,
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;

Votes

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
Engaged ,
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 😞

Votes

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
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

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

Votes

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
Engaged ,
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

Votes

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
Engaged ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

traceyc28668387_0-1594849223277.png

This pops up when I hit Clear Form

Votes

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
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

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

Votes

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
Engaged ,
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 😞

Votes

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
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Because that triggers the validation event...

Votes

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
Engaged ,
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.

Votes

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