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

169
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
1 ACCEPTED SOLUTION
Community Expert ,
May 22, 2024 May 22, 2024

Copy link to clipboard

Copied

LATEST

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

View solution in original post

Votes

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
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

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