Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Exclude certain fields from push(f.name)
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Exclude certain fields from push(f.name)

 Post Reply Post Reply
Author
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Topic: Exclude certain fields from push(f.name)
    Posted: 03 Feb 2016 at 3:24pm
Hi, all.

      We have a form for collecting at least 5 years of previous address history.  If fewer than 5 years' worth is provided, we throw a message instructing the user to complete the remaining empty fields until sufficient address history is provided.  Here's where my problem arises...

      A particular field that I do NOT want included is showing in the app.alert.  In the example below, I was excluding the submit button, the read-only ssn field, all of the hidden/read-only fields where we keep internal comments, and a read-only instructional field called "t_warning" (well, trying to exclude that one). 

      Simply having the condition that a field be omitted if
f.readonly==false worked to exclude ssn but did not do the trick for the t_warning field.  Therefore, I tried adding the condition that the name could not be "t_warning".  Bah, that didn't work, either.

var emptyFields = [];

for (var i=0; i<this.numFields; i++)
{
 var f= this.getField(this.getNthFieldName(i));

 if(f.name!="t_warning" && f.type!="button" && f.readonly==false && f.hidden==false)
 {
   if(f.type=="text" && f.value=="")
   {
    emptyFields.push(f.name);
    getField("t_donotproceed").required=false;
   }
 }
}

if(emptyFields.length>0)
{
 if(getField("t_grandtotal").value < 1825)
 {
 getField("t_donotproceed").required=true;
 emptyFields.push(f.name);
 app.alert("You must fill in the following fields until you have supplied 5 years of address history :\n" + emptyFields.join("\n"));
 }
}

if (emptyFields.length>0)
{
 if(getField("t_grandtotal").value > 1825)
 {
  getField("t_donotproceed").required=false;
 }
}


uploads/2117/t_warning_in_push_fields.PNG
      Any ideas for excluding particular fields?  We are moving to exclude countries, and I don't want the message to confuse the users.

TIA,
morrison

Back to Top
Sponsored Links


Back to Top
Horndoggie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 15 Jul 2011
Location: USA
Points: 758
Post Options Post Options   Quote Horndoggie Quote  Post ReplyReply Direct Link To This Post Posted: 03 Feb 2016 at 3:37pm
You may want to rethink this.  I lived at the same address for 30 years.  I worked at the same company for 20.  I would have no information for the remaining fields.  I may have missed it, but the code does not seem to allow for that.
Doug
Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1112
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 03 Feb 2016 at 3:54pm
if(emptyFields.length>0)
{
 if(getField("t_grandtotal").value < 1825)
 {
 getField("t_donotproceed").required=true;
 emptyFields.push(f.name);    // Why did you push f.name here ???
 app.alert("You must fill in the following fields until you have supplied 5 years of address history :\n" + emptyFields.join("\n"));
 }
}
Back to Top
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Posted: 03 Feb 2016 at 9:41pm
I didn't include all of the code because my question was only about excluding certain fields from displaying in the error message.  There is other code in place which does the to/from calculations at each previous address.  There is also a grand total field (hidden/read-only) that serves as a container where the values of the time spent at each previous address are added up.  Lastly, we have another hidden/read-only field which remains required until the condition is met that at least 5 years' worth of address history is supplied.  As soon as enough to/from dates are completed to give us a total greater than 1825 days (we're not pinning them down to 1826.25 days or greater), we flip the conditionally required, hidden/read-only field to optional.  These are the client's business rules, not ours.

My problem is that a field the user can't possibly complete((t_warning, which only displays instructions) is showing up in the message that the user must "complete the following fields until at least 5 years' worth of address history is supplied".  Basically, the client wanted to say that unless you have supplied sufficient address history, every field is required.  As long as the grand total is greater than 1825 days, you won't get the message to complete any empty fields.  Now that the client is wanting to exclude the country fields from the message, we're in a pickle.

BTW, with your stable history, you would never receive the message.  :-)
Back to Top
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Posted: 03 Feb 2016 at 9:58pm
BAlheit,

I don't know.  :-(  I don't know enough about it to know how it behaves.  This is code somebody else -- who, at the time, knew about as much as I do currently -- pieced together from bits and bobs of helpful info offered here on Planet PDF.  Only the original code had errors in it, and it never worked to push the field names.  I played around with it a little and got it to work... except for that stinkin' t_warning still displaying.

Basically, my goal is this:
  • Get the totals for each previous address to/from date values converted into days. (Check)
  • Add the values from each previous address and compare to our goal of "greater than 1825 days".  (Check)
    * BTW, this does not account for gaps in history.  Client just wants an overall grand total on all supplied addresses.  Client follows up with user if more info required.
  • Prevent the user from saving the form if fewer than 5 years' worth of history is provided. (Check)
  • Locate all the empty, editable text fields -- except country fields (new rule not yet in place) -- and push the names into an error message that the user recieves if he or she tries to save the form without providing greater than 1825 days' worth of address history.  (Fail, since I can't even keep t_warning from displaying, and that's hidden!)
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 629
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 03 Feb 2016 at 11:46pm
This code looks like something I posted a while back for validating required fields, although it has been edited quite a bit since then...

The way you edited the first if-condition in the for loop should have worked to ignore that field.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1112
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 04 Feb 2016 at 9:52am
Remove the line which I have marked.
Back to Top
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Posted: 04 Feb 2016 at 1:54pm
BAlheit,

Yes! It worked.  Thank you!  I am now able to exclude all those country fields by name, and the t_warning tag does not display, even when solely excluded by its state of being read-only.

if(emptyFields.length>0)
{
 if(getField("t_grandtotal").value < 1825)
 {
 getField("t_donotproceed").required=true;
 emptyFields.push(f.name);   //removed this
 app.alert("You must fill in the following fields until you have supplied 5 years of address history :\n" + emptyFields.join("\n"));
 }
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.047 seconds.