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

How to avoid a double percentage ?

Explorer ,
May 22, 2024 May 22, 2024

Copy link to clipboard

Copied

Hi, I have this code to bring a percentage automatically after the number :

if (event.value) event.value += "%";

 

What's the code to make it happen, but only if someone didn't write a percentage themselves in the first place ?

TOPICS
How to , JavaScript , PDF forms

Views

48

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

correct answers 1 Correct answer

Community Expert , May 22, 2024 May 22, 2024

if (event.value && /%$/.test(event.value)==false) event.value += "%";

Votes

Translate

Translate
Community Expert ,
May 22, 2024 May 22, 2024

Copy link to clipboard

Copied

LATEST

if (event.value && /%$/.test(event.value)==false) 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