Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Number format question

Avatar

Level 3

I have a field that should be in percent, so I want people to only be able to enter numbers from 0 to 100.  I know I can set ZZZ as my pattern, but that will also allow 999, for instance.  Is there a simple way (other than coding) to implement that?  If not, I'll do the code, but just curious if I was missing something.

The question of limiting the sign of a numerical entry (positive or negative) applies to some other formatting issues I have, so any information specificly about that is helpful also, even if you don't know about limiting the ZZZ to <= 100.

Thanks

2 Replies

Avatar

Level 4

Why dont you just put this JavaScript on the exit event of the field (make sure you select JavaScript as the script language):

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

xfa.host.messageBox("The percentage must be between 0 and 100");

}

You can make the field a decimal field,  Limit leading digits to 3 and de-select the trailing digits. I think thats what you're after.

Avatar

Level 10

The patterns will only indicate a zero or a number or a letter. It will not restrict the entry to a value. You will have to use code.

Paul