Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Specify a range for a Numeric Field

Avatar

Level 1

I have a numeric field in a form. I want to restrict the valid entries to 0 - 30 only. I have tried using some script tips I found online, but all I get are errors. Is there anyway to do this without using a script? If script is the only way, I would certainly appreciate help. Thanks in advance!

- Rick

1 Accepted Solution

Avatar

Correct answer by
Level 10

On the Exit event of the field put you can put something like the following (make sure the Script Editor is set to JavaScript):

if (this.rawValue < 0 || this.rawValue > 30) {

          xfa.host.messageBox("Amount needs to be between 0 and 30.", "Error: Wrong Amount");

          this.rawValue = null;

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

On the Exit event of the field put you can put something like the following (make sure the Script Editor is set to JavaScript):

if (this.rawValue < 0 || this.rawValue > 30) {

          xfa.host.messageBox("Amount needs to be between 0 and 30.", "Error: Wrong Amount");

          this.rawValue = null;

}

Avatar

Level 1

Amazing... thanks SO MUCH!! If I did not shave my head, I would have pulled all my hair out by now. So simple!