7/28/2019 Javascript That Affects All Text Fields
1/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
Replies
CompTerra
J avascript that affects all text fieldsOct 22, 2009 2:05 PM
2057 Views 28 Replies Latest reply: DC Dowd, Apr 26, 2011 2:51 PM
I am now trying to figure out a script that will affect all text fields in the document, there would be a button that when
clicked would affect all text fields in the document.
Thank you
1. Gilad D (try67),
Oct 22, 2009 2:08 PM in reply to CompTerraReport
Can't be done without knowing their names.
|Mark as:
2. CompTerra,
Oct 22, 2009 2:20 PM in reply to Gilad D (try67)
Report
I am using the following now: this.getField(["TEXT"]); that affects all fields starting with TEXT...my issue is that not all fileds
may start with TEXT.
http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333770#2333770http://forums.adobe.com/message/3638676?tstart=0#3638676http://forums.adobe.com/message/3638676?tstart=0#3638676http://forums.adobe.com/message/2333727#2333727http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333770#2333770http://forums.adobe.com/message-abuse!input.jspa?objectID=2333727&objectType=2http://forums.adobe.com/message/2333828#2333828http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333727#2333727http://forums.adobe.com/message-abuse!input.jspa?objectID=2333828&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=2333828&objectType=2http://forums.adobe.com/message/2333727#2333727http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333828#2333828http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message-abuse!input.jspa?objectID=2333727&objectType=2http://forums.adobe.com/message/2333770#2333770http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333727#2333727http://forums.adobe.com/people/try67http://forums.adobe.com/message/3638676?tstart=0#3638676http://forums.adobe.com/message/2333770#2333770http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerra7/28/2019 Javascript That Affects All Text Fields
2/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
|Mark as:
3. Gilad D (try67),
Oct 22, 2009 2:24 PM in reply to CompTerra
Report
Are you 100% sure about that? It's not documented and I just tried it on a
form and it just returns NULL.
|Mark as:
4. CompTerra,
Oct 22, 2009 2:29 PM in reply to Gilad D (try67)
Report
100% positive...notice the [ inside the " in this.getField(["TEXT"]) I started with naming the field: this.getField("TEXT.0.1.2")
then found I could do the [TEST] inside quotes and that will affect all fields starting with TEXT...text.0 text.0.1 text.0.0.1,and so on.
|Mark as:
5. Gilad D (try67),
Oct 22, 2009 2:32 PM in reply to CompTerra
Report
I did, but what you are accessing are actually copies of the same field
("widgets"), not (strictly speaking) separate fields.
If you will remove the periods from their names it will not work anymore.
http://forums.adobe.com/message/2333864#2333864http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333828#2333828http://forums.adobe.com/message-abuse!input.jspa?objectID=2333864&objectType=2http://forums.adobe.com/message/2333833#2333833http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333864#2333864http://forums.adobe.com/message-abuse!input.jspa?objectID=2333833&objectType=2http://forums.adobe.com/message/2333870#2333870http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333833#2333833http://forums.adobe.com/message-abuse!input.jspa?objectID=2333870&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=2333870&objectType=2http://forums.adobe.com/message/2333833#2333833http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333870#2333870http://forums.adobe.com/people/try67http://forums.adobe.com/message-abuse!input.jspa?objectID=2333833&objectType=2http://forums.adobe.com/message/2333864#2333864http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333833#2333833http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message-abuse!input.jspa?objectID=2333864&objectType=2http://forums.adobe.com/message/2333828#2333828http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333864#2333864http://forums.adobe.com/people/try677/28/2019 Javascript That Affects All Text Fields
3/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
|Mark as:
6. CompTerra,
Oct 22, 2009 2:36 PM in reply to Gilad D (try67)
Report
That makes sense...
I do have many text fields and each one starts with text.0 and so on, so I am lucky for that, though the issue continues
with those fields that may not have that name.
|Mark as:
7. Gilad D (try67),
Oct 22, 2009 2:39 PM in reply to CompTerra
Report
Like I said, those fields are copies of one another. If you change the value
of one of them, the rest will change as well.
|Mark as:
8. CompTerra,
Oct 22, 2009 2:46 PM in reply to Gilad D (try67)
Report
When you say value what do you mean? If I type the text 1234 into TEXT.0 then proceed to another field named TEXT.0.1
and type the text 5432 both values of those fields are different....I am confused in what your saying. Each field is its own
field, had I named two fields TEXT.0 then both fields are the same and if I type into one it will show in both.
|
http://forums.adobe.com/message/2333885#2333885http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333870#2333870http://forums.adobe.com/message-abuse!input.jspa?objectID=2333885&objectType=2http://forums.adobe.com/message/2333877#2333877http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333885#2333885http://forums.adobe.com/message-abuse!input.jspa?objectID=2333877&objectType=2http://forums.adobe.com/message/2333956#2333956http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333877#2333877http://forums.adobe.com/message-abuse!input.jspa?objectID=2333956&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=2333956&objectType=2http://forums.adobe.com/message/2333877#2333877http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333956#2333956http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message-abuse!input.jspa?objectID=2333877&objectType=2http://forums.adobe.com/message/2333885#2333885http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333877#2333877http://forums.adobe.com/people/try67http://forums.adobe.com/message-abuse!input.jspa?objectID=2333885&objectType=2http://forums.adobe.com/message/2333870#2333870http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333885#2333885http://forums.adobe.com/people/CompTerra7/28/2019 Javascript That Affects All Text Fields
4/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
Mark as:
9. Gilad D (try67),
Oct 22, 2009 2:48 PM in reply to CompTerraReport
But if you create TEXT.0 and TEXT.1 they will have the same value.
|Mark as:
10. CompTerra,
Oct 22, 2009 2:58 PM in reply to Gilad D (try67)
Report
Same value as in I copy TEXT.0 and paste somehwere then rename to TEXT.1? That would retain the original value of
course until I delete or change it. However if I create TEXT.0 then create TEXT.1 they are both seperate fields and do not
seem to retain any of the same values. I just did it to make sure....
|Mark as:
11. Gilad D (try67),
Oct 22, 2009 3:09 PM in reply to CompTerra
Report
You're right, it doesn't. It looks like it "tricks" Acrobat to think these
are widgets of the same field, when in fact the original field doesn't
exist.
|Mark as:
http://forums.adobe.com/message/2333929#2333929http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333956#2333956http://forums.adobe.com/message-abuse!input.jspa?objectID=2333929&objectType=2http://forums.adobe.com/message/2333966#2333966http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333929#2333929http://forums.adobe.com/message-abuse!input.jspa?objectID=2333966&objectType=2http://forums.adobe.com/message/2333999#2333999http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333966#2333966http://forums.adobe.com/message-abuse!input.jspa?objectID=2333999&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=2333999&objectType=2http://forums.adobe.com/message/2333966#2333966http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333999#2333999http://forums.adobe.com/people/try67http://forums.adobe.com/message-abuse!input.jspa?objectID=2333966&objectType=2http://forums.adobe.com/message/2333929#2333929http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2333966#2333966http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message-abuse!input.jspa?objectID=2333929&objectType=2http://forums.adobe.com/message/2333956#2333956http://forums.adobe.com/people/try67http://forums.adobe.com/message/2333929#2333929http://forums.adobe.com/people/try677/28/2019 Javascript That Affects All Text Fields
5/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
12. CompTerra,
Oct 22, 2009 3:12 PM in reply to Gilad D (try67)
Report
This is lucky for me....at least I have the "[TEXT]" option that will address all fields starting with that..
Thank you for your help.....if you can think of anything let me know!!
|Mark as:
13. Gilad D (try67),
Oct 22, 2009 3:21 PM in reply to CompTerra
Report
By the way, you don't need the square brackets. getField("TEXT") should work
as well.
|Mark as:
14. MarkWalsh,
Oct 22, 2009 3:22 PM in reply to CompTerra
Report
Is this what you are looking for?
function processTextFields () {
for(var i=0;i
7/28/2019 Javascript That Affects All Text Fields
6/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
if (oField.type == 'text') {
// Do something here
}
}
}
}
|Mark as:
15. CompTerra,
Oct 22, 2009 3:25 PM in reply to MarkWalsh
Report
I have not tried yet....this will affect all text fields? I want to be able to click a button and have all text fields affected with
the proceeding action.
|Mark as:
16. Gilad D (try67),
Oct 22, 2009 3:35 PM in reply to MarkWalsh
Report
Nice one. I totally forgot about this...
|Mark as:
17. MarkWalsh,
Oct 23, 2009 5:37 AM in reply to CompTerra
http://forums.adobe.com/message/2334036#2334036http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2334050#2334050http://forums.adobe.com/message-abuse!input.jspa?objectID=2334036&objectType=2http://forums.adobe.com/message/2334090#2334090http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/2334050#2334050http://forums.adobe.com/message-abuse!input.jspa?objectID=2334090&objectType=2http://forums.adobe.com/message/2335539#2335539http://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/message/2334036#2334036http://forums.adobe.com/message/2334036#2334036http://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/message/2335539#2335539http://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/message-abuse!input.jspa?objectID=2334090&objectType=2http://forums.adobe.com/message/2334050#2334050http://forums.adobe.com/people/try67http://forums.adobe.com/message/2334090#2334090http://forums.adobe.com/people/try67http://forums.adobe.com/message-abuse!input.jspa?objectID=2334036&objectType=2http://forums.adobe.com/message/2334050#2334050http://forums.adobe.com/people/CompTerrahttp://forums.adobe.com/message/2334036#2334036http://forums.adobe.com/people/CompTerra7/28/2019 Javascript That Affects All Text Fields
7/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
Report
Yes. The first loop:
will loop thorugh all of the fields in the document. The second loop:
will loop through all of the widgets for that field. You can eliminate the second loop if you don't need to work with the actualwidgets.
You can change the If statement to something else if you want to process other types of fields (i.e. combo boxes)
CompTerra wrote:
I have not tried yet....this will affect all text fields? I want to be able to click a button and have all text fields
affected with the proceeding action.
for(var i=0;i
7/28/2019 Javascript That Affects All Text Fields
8/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
};
this.mailDoc({
bUI: false,
cTo: "[email protected]",
cSubject: "Form" + " " + this.getField("DesiredField01").value + " " + this.getField("DesiredField02").value + " " +
this.getField("Date").value,
});
|Mark as:
19. Gilad D (try67),
Apr 25, 2011 3:16 AM in reply to DC Dowd
Report
Of course you can set the subject. You're doing so in your own code by setting the value of cSubject.
If you want to condition sending the email on on the text fields being filled-in, use the loop described earlier in this form to
check the value of the fields.
If any of them is empty, exit the function by calling "return;", otherwise the script will continue to the line that sends the
email.
Be aware that there's no such command as "noreturn" in J S.
|Mark as:
20. DC Dowd,
Apr 25, 2011 8:40 AM in reply to Gilad D (try67)
Report
Right, then. Here's the code I'm inserting into my document.
function processTextFields () {
for(var i=0;i
7/28/2019 Javascript That Affects All Text Fields
9/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
I'm getting nothing when the required fields are not filled in, which I rather expected. However, when all fields are filled in I
am still getting no response from the button. The mailDoc bit of code is working fine with no other code attached, but every
attempt at validating the form's required fields is causing trouble.
A thought occurs to me (I'm new at J S coding), but this code is referencing EVERY field in the document, right? This
would mean I should get no result even if the non-required fields are filled out (if my understanding is correct). Can this
code be modified to only apply to required fields? Thanks for the help in getting this far.
Using Acrobat 9.
return;
} else {
this.mailDoc({
bUI: false,
cTo: "[email protected]",
cSubject: "Form" + " " + this.getField("SiteName01").value + " " + this.getField("SysSN").value + " " +
this.getField("Date").value,
});}
};}}
|
Mark as:
21. Gilad D (try67),
Apr 25, 2011 9:50 AM in reply to DC Dowd
Report
You have quite a few mistakes in your code. Use this instead:
function processTextFields () {
for (var i=0; i
7/28/2019 Javascript That Affects All Text Fields
10/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
Mark as:
22. DC Dowd,
Apr 25, 2011 10:19 AM in reply to Gilad D (try67)Report
Copied and pasted that code to avoid further mistakes. Still not getting anything, even when all text fields are filled in.
Adobe gives no error in the code, just doesn't run it when I extend features and open the form in Reader (which is where
those who will use the form will be opening it).
I keep shuddering at the thought that someone is going to say I should use the built-in "Submit button" option, which would
validate all required fields without the hassle. However, that feature is exactly where I am having trouble getting the subject
line of my e-mail to pull the contents of fields in the form.
Thanks for the code help. Going to keep chipping away at it and running through the API for more insight.
|Mark as:
23. Gilad D (try67),
Apr 25, 2011 10:23 AM in reply to DC DowdReport
Are you calling the function from anywhere?
|Mark as:
24. DC Dowd,
Apr 25, 2011 10:28 AM in reply to Gilad D (try67)
Report
The script is being run on the mouse up of a button that is being used to submit the form.
Not being called from anywhere, just being run when that button is clicked.
http://forums.adobe.com/message/3635557#3635557http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3635495#3635495http://forums.adobe.com/message-abuse!input.jspa?objectID=3635557&objectType=2http://forums.adobe.com/message/3635566#3635566http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/3635557#3635557http://forums.adobe.com/message-abuse!input.jspa?objectID=3635566&objectType=2http://forums.adobe.com/message/3635559#3635559http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3635566#3635566http://forums.adobe.com/message-abuse!input.jspa?objectID=3635559&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=3635559&objectType=2http://forums.adobe.com/message/3635566#3635566http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3635559#3635559http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message-abuse!input.jspa?objectID=3635566&objectType=2http://forums.adobe.com/message/3635557#3635557http://forums.adobe.com/people/try67http://forums.adobe.com/message/3635566#3635566http://forums.adobe.com/people/try67http://forums.adobe.com/message-abuse!input.jspa?objectID=3635557&objectType=2http://forums.adobe.com/message/3635495#3635495http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3635557#3635557http://forums.adobe.com/people/DC%20Dowd7/28/2019 Javascript That Affects All Text Fields
11/12
be Community: Javascript that affects all text fields
//forums.adobe.com/thread/510983?decorator=print&displayFullThread=true[6/27/2013 1:38:42 AM]
|Mark as:
25. Gilad D (try67),
Apr 25, 2011 10:33 AM in reply to DC Dowd
Report
Yes, but you must call the function, or the code within it won't execute.
Add this as the last line, after everything else:
processTextFields();
|Mark as:
26. DC Dowd,
Apr 25, 2011 10:50 AM in reply to Gilad D (try67)
Report
Excellent. That works perfectly.
Now to look into validating only required fields.
|Mark as:
27. MarkWalsh,
Apr 26, 2011 12:45 PM in reply to DC Dowd
Report
Change
if (oField.type == "text" && oField.value=="") {
to
if (oField.type == "text" && oField.value=="" && oField.required) {
http://forums.adobe.com/message/3635572#3635572http://forums.adobe.com/people/try67http://forums.adobe.com/people/try67http://forums.adobe.com/message/3635559#3635559http://forums.adobe.com/message-abuse!input.jspa?objectID=3635572&objectType=2http://forums.adobe.com/message/3635618#3635618http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3635572#3635572http://forums.adobe.com/message-abuse!input.jspa?objectID=3635618&objectType=2http://forums.adobe.com/message/3638459#3638459http://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/message/3635618#3635618http://forums.adobe.com/message-abuse!input.jspa?objectID=3638459&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=3638459&objectType=2http://forums.adobe.com/message/3635618#3635618http://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/message/3638459#3638459http://forums.adobe.com/people/MarkWalshhttp://forums.adobe.com/message-abuse!input.jspa?objectID=3635618&objectType=2http://forums.adobe.com/message/3635572#3635572http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3635618#3635618http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message-abuse!input.jspa?objectID=3635572&objectType=2http://forums.adobe.com/message/3635559#3635559http://forums.adobe.com/people/try67http://forums.adobe.com/message/3635572#3635572http://forums.adobe.com/people/try677/28/2019 Javascript That Affects All Text Fields
12/12
be Community: Javascript that affects all text fields
Adobe
Community
powered
by J ive
SBS 4.5.6.3
forum
software
J ive Software
(Note - since this is only checking Text fields, you will need to make changes if you want it to validate required fields that
are not textfields - e.g. radio buttons, checkboxes, etc.)
|Mark as:
28. DC Dowd,
Apr 26, 2011 2:51 PM in reply to MarkWalsh
Report
Excellent!
Perfect. Works exactly as I need it to work. This forum rocks.
Thank you for your help.
|Mark as:
http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://forums.adobe.com/message/3638676#3638676http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3638459#3638459http://forums.adobe.com/message-abuse!input.jspa?objectID=3638676&objectType=2http://forums.adobe.com/message-abuse!input.jspa?objectID=3638676&objectType=2http://forums.adobe.com/message/3638459#3638459http://forums.adobe.com/people/DC%20Dowdhttp://forums.adobe.com/message/3638676#3638676http://forums.adobe.com/people/DC%20Dowdhttp://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/http://www.jivesoftware.com/poweredby/