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

Numeric field validation

kvdvijaykumar
Level 4
Level 4

How to set the limit length of a numeric field?

The numeric field should accept only 15 digits (including decimal if any)/

Any help?

Thanks,

VJ

3 Replies
SaketSidana
Employee
Employee

Enable "Comb of" checkbox and set 15 characters as the limit for the numeric field.

kvdvijaykumar
Level 4
Level 4

HI Saket,

Limit Length of 15 doen't mean that user needs to enter all the 15 digits.

As per my understanding, using "Comb Of" is advised wen the user is required to enter all the 15 digits.

Also, using "Comb Of" property will display 15 boxes inside the field and this shouldn't be there for my requirement.

Any other suggestion is welcome.

Thanks,

VJ

SaketSidana
Employee
Employee

Somehow, I took these as separate queries. You would need to write a script to do that.

Write a JS on change event of the numeric field.

// form1.sf1.NumericField1::change - (JavaScript, client)

var chkLength;

chkLength = xfa.event.newText.length;

     if (chkLength > 15) {

     xfa.event.change = "";

     xfa.host.messageBox("Only 15 characters allowed", "Incorrect input", 1);

     }

This would not allow a user to enter more than 15 digits including decimal and that too while entering the data. Perhaps, a user friendly way and you may like this. He can however enter less digits. Try it out and modify it accordingly to cater to the case not to allow less than 15 digits. I haven't tried it out with the new Text function and perhaps, you may need to write a script at exit event to check for < 15 digits.