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

Zero (0) not accepted as a value in required box

Explorer ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Hello,

 

Apologies for the stupid quiestion! Im very new at this!

 

I have a peice of code that will let the user know that required text fields have not been filled in. the code is as follows:

 

if(this.getField("Text Field 1").value == "")

{

app.alert("must be filled in");

}

else if (this.getField("Text Field 2").value == "")

{

app.alert("must be filled in");

}

else

{

this.mailDoc({cTo: "Email Address", cSubject: this.getField("Text Field 1").valueAsString})

}
;

 

This works except it will not allow for an input of zero. This is fine on Text Field 1 as it should always be submitted as a 6 digit number, however on Text Field 2 it can be zero

 

I have tried setting as a numerical text field although this did not work

TOPICS
Acrobat SDK and JavaScript

Views

267

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 , Nov 08, 2021 Nov 08, 2021

Use "===" instead of "==", and valueAsString instead of value.

Votes

Translate

Translate
Community Expert ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Use "===" instead of "==", and valueAsString instead of 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
LEGEND ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

LATEST

JavaScript is designed to make things easier for the programmer. In most languages things can be a string or a number but not both, but JavaScript magically converts. This is one of those cases where it is a complete pain.... !

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