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

Remove any initial spaces from field - scripts?

New Here ,
Sep 13, 2022 Sep 13, 2022

Copy link to clipboard

Copied

Is there a way to remove any initial spaces for a text field. So if user enters: [ Bill] it formats it to: [Bill].

 

This is for a validation check so the user cannot just enter spaces and is required to enter a name. Maybe a way to check for letters as well. 

 

if (getField("step1.namefield").valueAsString === ""){

( As spaces pass check for this) 

 

TOPICS
Create PDFs , JavaScript , PDF forms , Standards and accessibility

Views

136

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
Community Expert ,
Sep 15, 2022 Sep 15, 2022

Copy link to clipboard

Copied

LATEST

You should use the "trim()" method: https://www.w3schools.com/jsref/jsref_trim_string.asp

Be careful, PDF-JavaScript (ECMAScript) does not support "let", use "var" instead.

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