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

how to fix a JavaScript Warning to disable a date field

New Here ,
Jan 27, 2025 Jan 27, 2025

Hello all, I'm revisiting this error that I can't seem to shake. It's kind of weird that when I turn off the custom formatting in the field I am trying to hide, the function works then I change it back. It works after changing it back. Then somewhere along the way it reverts and give off the error warning: JavaScript Window -

"Invalid date/time: please ensure that the date/time exists. Field [ArrestFile.1.Person.DOA ] should match format yyyy/mm/dd"

It does match this custom date format. I'm scracthing my head at this point. Had this form way too long now. Someone help if possible... much appreciated any help at all.

TOPICS
How to , JavaScript , PDF , PDF forms
857
Translate
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 ,
Jan 27, 2025 Jan 27, 2025

Please upload the form.

Translate
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 ,
Jan 27, 2025 Jan 27, 2025

Sounds like badly formatted data is being entered into the field. We really need to look at the form to tell what's going on.

However, you may find this article helpful:

https://www.pdfscripting.com/public/Value-Entered-Does-Not-Match-Format.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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
New Here ,
Jan 28, 2025 Jan 28, 2025

thank you however, unfortunately this form is on a classified side so I am unable to send a copy. I also cannot screenshot. The best thing I could do is type any syntax word from word which is a bit much. Is there any other way to mitigate this? I checked out the link & although I essentially understand, it doesn't apply to my situation. I think it's because it's a date field that I am referencing for whatever reason. But it is the correct date format that its supposed to be. 

Translate
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 ,
Jan 28, 2025 Jan 28, 2025

Make a demo PDF that uses the same same formatting and scripts, then post it.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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
New Here ,
Jan 30, 2025 Jan 30, 2025

Thank you for the reference however, I couldn't relate it to my situation. I managed to extract the full code which is 31 pages in total by taking a pic with my phone. Unfortunately I will have to convert every last one of them from a unsupported HEIC file. 

I'm sending you one to see if you can view this. I'm assuming you need all 31 pages to be able to assist?

Thank you for your help.

 

Please see attached, let me know if your unable to read it.

Translate
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 ,
Jan 30, 2025 Jan 30, 2025

Where do you set the value of the date field?

Translate
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
New Here ,
Jan 30, 2025 Jan 30, 2025

I think its the following?

function SetPubDate()

{

      var PubDate=this.info.FormRevision;

      var PubDateFld=event.name==="Format"?event:this.getField("DocPubDate");

 

      if (pubDate&&(pubDateFld.value!==pubDate))  {

             pubDateFld,value!==pubDate;

             console.prin1n("Set PubDate: " + PubDateFld.value);

       }

}

Translate
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 ,
Jan 30, 2025 Jan 30, 2025

Check the Javascript console for errors (ctrl-j).

Translate
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 ,
Jan 30, 2025 Jan 30, 2025

Is this.info.FormRevision custom info?  The format probably doesn't match.  You should add brackets to this line:

var PubDateFld=(event.name==="Format"?event:this.getField("DocPubDate"));

Translate
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 ,
Jan 30, 2025 Jan 30, 2025

Also, it looks like you have a comma instead of a period:

pubDateFld,value!==pubDate;

 

As @Bernd Alheit says, check th console for errors.

Translate
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
New Here ,
Jan 31, 2025 Jan 31, 2025

Yea... your right. Wasn't thinking, I suppose out of desparity.  lol! 

However, my predecessor is not here. Besides I believe I did the whole kitchen (document)

I don't want this to get lost in translation.

All I need is the ResetPartialDOA date field to disappear or rather hide when the ArrestFile.1.Content.EntireRecordYN checkbox is clicked. I got it to work but it added an error code. So I did some research & test & it apparently works fine for text boxes & check boxes which is currently happening. However, I figured that this function just doesn't like the date field. So what I did was put a script in the field that is supposed to be a date field. I used the "Custom Keystroke" Script: 

if (event.change)  {

     event.rc = /^[0-9, \/\(/)]+$/.test(event.change);

}

for the field I am trying to hide when the checkbox is clicked. It works but unfortunately the default text field shows the word Off. 

 

I think its something that is extra in this script for the word "Off" to be shown in the field. 

 

I tried adding this script to fix it: 

if (event.target.value === "off")  {

     this.getfield("ArrestFile.1.Person.DOA") .display = display.hidden;

     this.getfield("ArrestFile.1.Person.DOA") .value = " ";

} else {

      this.getfield{"ArrestFile.1.Person.DOA") .display = display.visible;

}

 

To try & get rid of the word Off.

Am I doing too much or not enough?

 

I appreiciate your help if any!

 

See below of the scripts being ran please:

 

ClearRelated Script:

 

function ClearRelated(obj1,obj2,permVisible)

{

        //console.print1n("obj1.name: "+obj1.value);

        //console.print1n("obj2.name: "+obj2.value);

        obj2.value= ((obj1.value!=="Off")

                              ?(()=>{

                                           obj2.display=((!permVisible)?display.hidden:display.visible);

                                            return "Off";

                                           }) ()

                                : ( ( ) =>{

                                              obj2.display=display.visible;

                                              return obj2.value;

                                             }) () ) ;

}

 

ResetPartialDOA Script:

 

function ResetPartialDOA(obj1,obj2)

{

        console.print1n(obj1.name: "+obj1.value);   

        console.print1n(obj2.name: "+obj2.value); 

        console.print1n(this.getField("RequestType.Seal") .name+ ": " + this.getField("RequestType.Seal").value); 

        

         obj2.display= ((obj1.value==="Off") | | (this.getField("RequestType.Seal").value!=="Off"))

                             ? ( ( ) =>{

                                            obj2.value=" ";

                                            return display.hidden;

                                        } ) ()

                             : ( ( ) => {

                                           obj2.value=obj2.value;

                                           return display.visible;

                                       } ) () ; 

 

SetPubDate Script:

 

function SetPubDate ()

{

        var pubDate=this.info.FromRevision;

        var pubDateFld=event.name==="Format"?event:this.getField("DocPubDate");

 

        if (pubDate&&(pubDateFld.value!==pubDate) )  {

               pubDateFld.value=pubDate;

               console.print1n("Set PubDate: " + pubDateFld.value);

        }

}

 

& last but not least the ToggleAllRelated Script

 

function ToggleAllRelated(numRows)

{

       for(var i=1;i<=numRows;i++) {

              var obj1=this.getField("ArrestFile."+i+".Content.PartialYN");

              var obj2=this.getField("ArrestFile."+i+".Content.PartialDesc");

              //console.print1n(obj2.name);

              ResetPartialDOA(obj1,obj2);

        }

}

 

Translate
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
New Here ,
Jan 31, 2025 Jan 31, 2025

I new addition will not even run.

 

It even says that there's an error on line 5 in the colon but I don't get it.

Translate
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
New Here ,
Jan 31, 2025 Jan 31, 2025

JUST tried something else & it works! They'll just have to live with typing the date in rather than clicking the dropdown menu.

Made adjustments and added it to the "ArrestFile.1.Content.EntireRecordYN" checkbox within the "ClearRelated" script so it now reads:

 

function ClearRelated(obj1,obj2,permVisible)

{

        //console.print1n("obj1.name: "+obj1.value);

        //console.print1n("obj2.name: "+obj2.value);

        obj2.value= ((obj1.value!=="Off")

                              ?(()=>{

                                           obj2.display=((!permVisible)?display.hidden:display.visible);

                                            return "Off";

                                           }) ()

                                : ( ( ) =>{

                                              obj2.display=display.visible;

                                              return obj2.value;

                                             }) () ) ;

}

 

if (event.target.value=== "Off")  {

     this.getField("ArrestFile.1.Person.DOA") .display = display.hidden;

     this.getField("ArrestFile.1.Person.DOA") .value = " ";

} else {

      this.getField("ArrestFile.1.Person.DOA") .display = display.visible;

}

Translate
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 ,
Jan 31, 2025 Jan 31, 2025

"Off" is the value of an unchecked check box.  I didn't go through it all but the O in "Off" should be upper case.  You have both upper and lower case in your script.

Translate
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
New Here ,
Jan 31, 2025 Jan 31, 2025

Yes... thank you. I actually realized that & made the change. Just gave an update on that with the corrected code that fixed it moments ago.

Translate
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
New Here ,
Jan 31, 2025 Jan 31, 2025
LATEST

I also took out some improper spacing & changed the { with a missing ( in the second this.getField line. thanks for your help. It works just not with the date format.

Translate
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 ,
Jan 30, 2025 Jan 30, 2025

So this code does not set any values. It only displays a message, except there is an error. 

 

This line has a syntax error that will be reported in the console window when it is run.

 

  1.   pubDateFld,value!==pubDate;

 

Notice the "," before value. 

 

So why are there 31 pages of code?  No one is ever going to look over that amount of code to provide free help. We only need the relevant bits.

However, if you have that much code, then the assumption is that the person who wrote it knows something about what they are doing. Perhaps you should talk to them.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 ,
Jan 30, 2025 Jan 30, 2025

That's not going to help.  Why not copy and paste the fields in question to a blank PDF and upload it?

Translate
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
New Here ,
Jan 30, 2025 Jan 30, 2025

Because this code/.pdf is on a classified computer. I unfortunately cannot copy anything from it. I'll try to find another way. I have 31 pages of it in fact where I snapped photos of each after copying & pasting it in word.

Translate
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