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

Remove leading zeros when null

Community Beginner ,
Nov 22, 2019 Nov 22, 2019

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!

TOPICS
How to , PDF forms
643
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 22, 2019 Nov 22, 2019

Use this:

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

else {

// rest of code goes here

}

 

View solution in original post

Translate
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
Community Expert ,
Nov 22, 2019 Nov 22, 2019

Use this:

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

else {

// rest of code goes here

}

 

Translate
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
Community Beginner ,
Nov 22, 2019 Nov 22, 2019

Perfect!! Thank you so much 🙂

Translate
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 13, 2020 Oct 13, 2020
LATEST

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. 

Translate
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