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

Validate for Multiple Ranges

New Here ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

Hi,

I am trying to validate a number field. The validate range function is great, but I have two ranges that a number can fall between. I need to validate the number as being .75 or in the range from 2.25 to 6.00.

 

I have ZERO idea how to even start that custom validation script in Java. I've searched the community to see if there is something similar, but I am at a loss.

 

Any help would be appreciated. Thank you!


Scot Motzny

TOPICS
Acrobat SDK and JavaScript

Views

271

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 1 Correct answer

Community Expert , Oct 05, 2020 Oct 05, 2020

You can use this code to do it:

 

if (event.value) {
	var v = Number(event.value);
	if ((v==0.75 || (v>=2.25 && v<=6))==false) {
		app.alert("Invalid value.");
		event.rc = false;
	}
}

Votes

Translate

Translate
Community Expert ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

You can use this code to do it:

 

if (event.value) {
	var v = Number(event.value);
	if ((v==0.75 || (v>=2.25 && v<=6))==false) {
		app.alert("Invalid value.");
		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
New Here ,
Oct 06, 2020 Oct 06, 2020

Copy link to clipboard

Copied

LATEST

Thank you so much for your help with this. That worked perfectly!

Much appreciation!

 

If you have a suggestion on where I can learn how to write Java calculations and validations I would appreciate that as well. Teach me to fish!

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