Skip to main content
This topic has been closed for replies.
Correct answer try67

No. At a time it will be either text or number. If I enter 10000, it should be formatted as 10,000. At some cases I will enter NONE. Usually if I enter text in numeric field, it won’t allow.


OK, then you can use this code as the field's custom Format script:

if (event.value && !isNaN(Number(event.value))) AFNumber_Format(2, 1, 0, 0, "", false);

2 replies

Participating Frequently
February 7, 2019

Is there a javascript to format a text field to have number format and allow text as well?

Below code i found can set the number format, but how to format the field to take a specific value XX. If i enter number it should be formatted in numeric format and should take the character XX as well.

this.getField("fieldname").setAction("Format", 'AFNumber_Format(0, 1, 0, 0, "", false)');

try67
Community Expert
Community Expert
February 7, 2019

Do you mean that if you enter "ABC" into the field it should stay the same, but if you enter "5" it should become "5.00" or something like that?

Participating Frequently
February 8, 2019

Exactly!!

try67
Community Expert
Community Expert
February 7, 2019

Not an existing one, but you can certainly write one... The tricky part will be to differentiate between a number and other text, and only apply the formatting to the former.

Participating Frequently
February 7, 2019

I am a newbie to JavaScript:(