Skip to main content
Participant
October 5, 2020
Answered

Validate for Multiple Ranges

  • October 5, 2020
  • 1 reply
  • 526 views

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

This topic has been closed for replies.
Correct answer try67

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;
	}
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 5, 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;
	}
}
smotznyAuthor
Participant
October 6, 2020

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!