Expand my Community achievements bar.

Numeric field validation

Avatar

Former Community Member

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

Avatar

Employee

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

Avatar

Former Community Member

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

Avatar

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.