Highlighted

Remove leading zeros when null

Community Beginner ,
Nov 22, 2019

Copy link to clipboard

Copied

Hello. I am using a cutom validation script to enter leading zeros in a text box.

 

(function() { var max_len = 9; var val = event.value; while (val.length < max_len) {val = "0" + val;} event.value = val; })();

 

The problem arises when the value is null the field reports "000000000." I would like for it to be blank if null.

 

Any help would be greatly appreciated!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this:

if (event.value==0) event.value = "";

else {

// rest of code goes here

}

 

TOPICS
How to, PDF forms

Views

82

Likes

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

Remove leading zeros when null

Community Beginner ,
Nov 22, 2019

Copy link to clipboard

Copied

Hello. I am using a cutom validation script to enter leading zeros in a text box.

 

(function() { var max_len = 9; var val = event.value; while (val.length < max_len) {val = "0" + val;} event.value = val; })();

 

The problem arises when the value is null the field reports "000000000." I would like for it to be blank if null.

 

Any help would be greatly appreciated!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use this:

if (event.value==0) event.value = "";

else {

// rest of code goes here

}

 

TOPICS
How to, PDF forms

Views

83

Likes

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
Nov 22, 2019 1
Most Valuable Participant ,
Nov 22, 2019

Copy link to clipboard

Copied

Use this:

if (event.value==0) event.value = "";

else {

// rest of code goes here

}

 

Likes

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
Reply
Loading...
Nov 22, 2019 2
Community Beginner ,
Nov 22, 2019

Copy link to clipboard

Copied

Perfect!! Thank you so much 🙂

Likes

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
Reply
Loading...
Nov 22, 2019 0
New Here ,
Oct 13, 2020

Copy link to clipboard

Copied

Hello,

Can please someone help me with this custom script. 

why is that only work on pc, when I open the same PDF with my android Mobile, The Zeros are comming back. 

Thank you. 

Likes

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
Reply
Loading...
Oct 13, 2020 0