Display error message on checkbox if drop down selected

Contributor ,
Jan 10, 2020

Copy link to clipboard

Copied

I have a checkbox named 'NoLieu' and a dropdown list named 'AbsenceType'.  Is it possible to display an error message and/or disable the user from being able to check the box if the user selects from one of the options in the Absence Type dropdown list?  Even better, if an error message could also appear if the user checks the No Lieu box first and then selects an option from the Absence dropdown list too.  I don't want them to be able to check the 'No Lieu' box at all if they select an Absence Type option.

Thanks!

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

Hi,

 

In the custom calculation script of your dropdown field, you can use something like this:

 

var a = this.getField("No Lieu").value;
var b = this.getField("Absence Type").valueAsString;


if(a=="Off") event.value=b;
else if (a=="Yes") event.value="";
if ( (b!=="") && (a=="Yes") ) app.alert("PLEASE NOTE: Only one selection is allowed",0);
TOPICS
Acrobat SDK and JavaScript

Views

160

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

Display error message on checkbox if drop down selected

Contributor ,
Jan 10, 2020

Copy link to clipboard

Copied

I have a checkbox named 'NoLieu' and a dropdown list named 'AbsenceType'.  Is it possible to display an error message and/or disable the user from being able to check the box if the user selects from one of the options in the Absence Type dropdown list?  Even better, if an error message could also appear if the user checks the No Lieu box first and then selects an option from the Absence dropdown list too.  I don't want them to be able to check the 'No Lieu' box at all if they select an Absence Type option.

Thanks!

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

Hi,

 

In the custom calculation script of your dropdown field, you can use something like this:

 

var a = this.getField("No Lieu").value;
var b = this.getField("Absence Type").valueAsString;


if(a=="Off") event.value=b;
else if (a=="Yes") event.value="";
if ( (b!=="") && (a=="Yes") ) app.alert("PLEASE NOTE: Only one selection is allowed",0);
TOPICS
Acrobat SDK and JavaScript

Views

161

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
Jan 10, 2020 0
Adobe Community Professional ,
Jan 12, 2020

Copy link to clipboard

Copied

Hi,

 

In the custom calculation script of your dropdown field, you can use something like this:

 

var a = this.getField("No Lieu").value;
var b = this.getField("Absence Type").valueAsString;


if(a=="Off") event.value=b;
else if (a=="Yes") event.value="";
if ( (b!=="") && (a=="Yes") ) app.alert("PLEASE NOTE: Only one selection is allowed",0);

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
Reply
Loading...
Jan 12, 2020 0
Contributor ,
Jan 13, 2020

Copy link to clipboard

Copied

Thank you so much!!  You are a gem!  It works like a charm 🙂

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
Reply
Loading...
Jan 13, 2020 0
ls_rbls LATEST
Adobe Community Professional ,
Jan 13, 2020

Copy link to clipboard

Copied

You're welcome. Happy to help.

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
Reply
Loading...
Jan 13, 2020 0