Skip to main content
Participant
June 9, 2023
Answered

required field gives error "ReferenceError: reExP is not defined"

  • June 9, 2023
  • 1 reply
  • 663 views

Hi, folks-- 
I'm learning Acrobat JavaScript by reading these forums. 


I have a document with required fields, and a "Clear" button. The user will generate a document, print it, click the "Clear" button, and generate the next document. I would like it to not error when clicking clear. How can I change my code to make the error not happen when the document is cleared (rather than when it's printed), please? 

 

The error is generated when the user clicks Clear. The user is notified that "the field is required", and needs to click through that notice. Then the form is cleared and ready to use again. 

The debugger Console says:

ReferenceError: reExP is not defined
1:AcroForm:IssueNum:Validate

 

The field is required under General Text Field properties, and has a custom validation script:

if (event.value == ""|| (event.value.length < 4 || event.value.length > 4 || !(reExP.test(event.value))))

if(event.value == "") {
app.alert("Issue Number is Required")
this.getField("IssueNumber").setFocus();
}

else if(event.value.length < 4) {
app.alert("Issue Number must be 4 characters")
this.getField("IssueNumber").setFocus();
}

else if(event.value.length > 4) {
app.alert("Issue Number must be 4 characters")
this.getField("IssueNumber").setFocus();
}

 

The Clear button code:

var Okay = 0;
Okay = app.alert("Do you want to erase all field data?", 1, 1);
if (Okay == 1) {
{this.resetForm()};
this.getField("Today").value = util.printd("d-mmm-yy", new Date());

}

This topic has been closed for replies.
Correct answer Bernd Alheit

Define/set the variable reExP.

1 reply

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
June 10, 2023

Define/set the variable reExP.

Participant
June 12, 2023

Well, I feel sheepish! Thank you.