• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Removing automatic "0" from Javascripted form field

New Here ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

Hi All,

 

I'm having a massive problem trying to remove the default "0" from a Javascripted form field.  I needed the field to be in the "xx xxx xxx xxx" numerical format, which has been figured out:

 

 

var x = Number(event.value).toFixed(0); 
event.value = 
event.value = " " + x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ").replace(/\./g, ',');

 

 

But this unfortunately means that now the field defaults to "0" when opening the file.  I've searched the forums and have been unable to come up with any kind of solution that maintains the integrity of the format.  If anybody can provide some help it'd be really appreciated, thanks!

Views

414

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

For a number I use the following Custom Format Script:

 

if(event.value == o) {

event.value = "";

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Hi, thanks for your response, but if I add that, then the xx.xxx.xxx.xxx formatting for the numbering is lost.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

You are dealing with a string value and not a numeric value.

 

Try as a custom format script:

 

var x = Number(event.value).toFixed(0);
if(event.value == 0){
event.value = "";
} else {
event.value = " " + x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ").replace(/\./g, ',');
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

LATEST
Thank you again, does that mean that there is no way to get numbers to automatically format into the "1 123 123 123" format (rather than the 1,123,123,123 format) without there being a "0" in the field prior to entry?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines