Expand my Community achievements bar.

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

Former Community Member

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

Former Community Member

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