Javascript that affects all text fields

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

Right, then. Here's the code I'm inserting into my document.
function processTextFields () {
     for(var i=0;i<this.numFields;i++) {
          // Loop through all fields on document
          var fldName = this.getNthFieldName(i);
          var oField = this.getField(fldName);
          var a = oField.getArray();
          for (j =0; j < a.length; j++) {
          if (oField.type == "") {
          return;
          } else {
this.mailDoc({
bUI: false,
cTo: "[email protected]",
cSubject: "Form" + " " + this.getField("SiteName01").value + " " + this.getField("SysSN").value + " " + this.getField("Date").value,
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 JS 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.

Similar Messages

  • How do I use Javascript to populate a text field based on a selection from a drop down box?

    Greetings,
    I have virtually no experience with JavaScript and I am trying to figure out how to add some basic automation features to an Adobe form.  I have a drop down box called "Hospital_Name" that will contain approximately 7 possible selections.  When the user makes a selection, I would like to have the text field (called "Hospital_Address") below the drop down box populate with the corresponding address for the selection.  I have the "Hospital_Address" text field configured for multiple lines and would like the address to have a line break between the street address and the city/state/zip.
    For example, if the user selected "Hospital 1", the text field would display:
    123 Main St
    Anytown, CA 12345
    Any help or examples you can provide would be greatly appreciated.

    You have the element names within the object within brackets.
    Make sure your brackets are properly placed and matched.
    // Place all pre-population data into a single data structure
    var Location = {
    "--Hospital--":{ line1: " ", line2: " " },
    "Bellevue Medical Center":{ line1: "2500 BMC Drive", line2: "Bellevue, NE 68123" },
    "CHI Bergan Mercy":{ line1: "7500 Mercy Road", line2: "Omaha, NE 68124" }, 
    "CHI Immanuel":{ line1: "6901 N. 72nd Street", line2: "Omaha, NE 68122" }, 
    "CHI Lakeside":{ line1: "16901 Lakeside Hills Court", line2: "Omaha, NE 68130" }, 
    "CHI Midlands":{ line1: "11111 S. 84th Street", line2: "Papillion, NE 68046" },
    "Creighton University Medical Center":{ line1: "601 N. 30th Street", line2: "Omaha, NE 68131" },
    "Nebraska Medical Center":{ line1: "4400 Emile Drive", line2: "Omaha, NE 68105" }
    // some debugging code to see location names;
    console.show();console.clear():
    for(I in Location) {
    console.println(I);
    // end debugging code;
    function SetFieldValues(Hospital_Name) {
        this.getField("AddLine1").value = Location[Hospital_Name].line1;
        this.getField("AddLine2").value = Location[Hospital_Name].line2;
    This is not a beginners task but requires a fair amount of knowledge about the structure of objects, defining strings, and structure of arrays.
    Are you sure you have all the field names correctly spelled and capitalized?
    Do you get any error in the JavaScript console?
    Just trying the line that defines the "Location", I get the following error:
    SyntaxError: invalid property id
    1:Console:Exec
    undefined
    All the form field in a PDF are processed by using JavaScript and any error in any script will stop JavaScript processing.
    It might help to have a link to the problem form.
    Make sure your brackets are properly placed and matched.
    // Place all pre-population data into a single data structure
    var Location = {
    "--Hospital--":{ line1: " ", line2: " " },
    "Bellevue Medical Center":{ line1: "2500 BMC Drive", line2: "Bellevue, NE 68123" },
    "CHI Bergan Mercy":{ line1: "7500 Mercy Road", line2: "Omaha, NE 68124" }, 
    "CHI Immanuel":{ line1: "6901 N. 72nd Street", line2: "Omaha, NE 68122" }, 
    "CHI Lakeside":{ line1: "16901 Lakeside Hills Court", line2: "Omaha, NE 68130" }, 
    "CHI Midlands":{ line1: "11111 S. 84th Street", line2: "Papillion, NE 68046" },
    "Creighton University Medical Center":{ line1: "601 N. 30th Street", line2: "Omaha, NE 68131" },
    "Nebraska Medical Center":{ line1: "4400 Emile Drive", line2: "Omaha, NE 68105" }
    function SetFieldValues(Hospital_Name) {
        this.getField("AddLine1").value = Location[Hospital_Name].line1;
        this.getField("AddLine2").value = Location[Hospital_Name].line2;

  • Make all text fields read only after signing form

    Hello,
    I have a live cycle form which needs to have all of the text fields set as read only after signing.
    The java script has been placed in the post sign event of a digital signature field.
    for(var i=0;i<this.numFields;i++) {
    var cNm = this.getNthFieldName(i);
    if (cNm.type = "text") this.getField(cNm).readonly = true;
    After signing the form the following console error is shown:
    this.getNthFieldName is not a function
    Can anyone please advise how to revise the script so that when the form is signed all of the text fields become ready only?
    Any assistance will be most appreciated.
    Thank you.

    You don't need any JavaScript to do this.
    In Designer you can setup the signature field in that way, that all fields will be locked after signing.
    Look here:
    http://forums.adobe.com/message/3121870?tstart=2

  • Using Javascript to change multiple text field names

    I have a pdf with multiple text fields. I need to change all the text field names (General -> Name) so that they are unique so that when I combine multiple pdfs together, the text fields will stay intact. Is there anyway to do this using javascript? Thanks!

    I'm new to javascript too...it will be very helpfull for me too...Thanks
    poltrone
    prodotti chimici

  • Trim All Text Field quickly?

    Currently i got over +40 textfields which uses DML and the column is 255 VARCHAR
    Wondering if there a quick way of trimming all these fields before the update happens.
    As of right now im doing it like this... is there way a to grab all textfield and just loop and trim or something simliar....? i was thinking of using javascript and copy paste 40 names in an array and loop trim and set value but that seem ugly to me. as i have to go in to it every time if a new field is needed...
    :P1_name := trim(:P1_name)
    :P1_boat := trim(:P1_boat)
    :P1_book := trim(:P1_book)
    :P1_game := trim(:P1_game)
    :P1_phone := trim(:P1_phone)
    :Px_item := trim(:Px_item)Edited by: PandaOracle on Feb 14, 2012 2:19 PM

    Hello PandaOracle,
    >
    PandaOracle wrote:
    As of right now im doing it like this... is there way a to grab all textfield and just loop and trim or something simliar....? i was thinking of using javascript and copy paste 40 names in an array and loop trim and set value but that seem ugly to me.
    >
    Instead of JavaScript there is a jQuery solution to you problem. Here is a JavaScript function you can call on your Submit button of your page:
    function f_trim_textb() {
      //trim all the text fields
      $('input[type="text"]').each(function() {
       oval = $(this).val();
       tval = $.trim(oval);
       $(this).val(tval);
      //submit the page
      apex.submit({request:"SUBMIT"});
    }Refer: http://api.jquery.com/jQuery.trim/
    Well however this is not the only solution! You can use PL/SQL process that executes before page submit and do thing what you have suggested above:
    :P1_name := trim(:P1_name)
    :P1_boat := trim(:P1_boat)
    :P1_book := trim(:P1_book)
    :P1_game := trim(:P1_game)
    :P1_phone := trim(:P1_phone)
    :Px_item := trim(:Px_item)Yet another solution is setting the attribute Post Calculation Computation in the Source section of Item Attributes to:
    trim(:Px_item)Hope it helps!
    Regards,
    Kiran

  • My calculation "Total" box adds sum of all text fields whether they are visible or not, do I change

    I have check boxes that show and hide text fields. (Thanks to Gilads Java script). In options I have a default value for each text field.
    My "Total" Field field adds all fields even if they are not checked and visible. Need to have it only include them if they are checked and visible.

    You can't attach forms by email, or any other means, so it didn't come through.
    Since your fields have default values and aren't calculated based on the state of the corresponding check box, you will have to use a custom calculation script for the Total field that can check to see if any of the fields are hidden, and if so, don't include their values in the sum. For example:
    // Custom calculation script
    (function () {
        // Set up an array of field names to include in the total
        var aFields = ["text1", "text2", "text3", text4"];
        // Initialize variables
        var i, f, sum = 0;
        // Loop through the fields an calculate the sum
        for (i = 0; i < aFields.length; i += 1) {
            // Get the current field
            f = getField(aFields[i]);
            // Add the value of the current field to the sum if the field is visible
            if (f.display == display.visible) {
                sum += +f.value;
        // Set this field value to the sum
        event.value = sum;
    You can send me a PM if you want help offline.

  • Do I need to use javascript to get a text field in a PDF form to aut fill with current/today's date?

    I have a form for booking appointments and would like the date field to automatically fill with
    today's date and to print. I have set the text field's format to "Date" and when I place the cursor into the
    date field, today's date shows. It disappears as soon as I tab to the next field.
    Does this action require a javascript script to fill and print today's date? If so, where do I find that?
    Or is there another way to format the text field (besides typing today's date) to get the current date?
    Thanks.
    Ali
    using iMac 2.93 GHz Intel Core 2 Duo 8 GB | OS Snow Leopard 10.6.8 | Acrobat Pro 8

    Thank you GKaiseril!
    From the examples by Chris Dahl, I edited the script in the text field editing dialog to reflect the title I had given the field. That fixed the problem of today's date disappearing as soon as I tabbed to the next field.
    How do I choose for document level or page open script? I would like it to insert the date upon opening the document.
    Thanks again.
    Ali
    NOTE: I found the answer within Chris Dahl's tutorial... path is for Acrobat Pro 8: Advanced>Document Processing>Document Javascripts

  • How to get the handle of all text fields in the subforms, using script

    Hi Friends,
    I have around 20 fields in a subform, how can i get the names of all the fields using script.
    I wish to enhance the following script where the field names are hard coded
    thereby the script itself will get the names of the field names.
    var f1 = this.parent.somExpression + ".TextField2" + ",";
    var f2 = f1 + this.parent.somExpression + ".DropDownList1" + ",";
    var f3 = f2 + this.parent.somExpression + ".NumericField1";
    xfa.host.resetData(f3);
    Any help will be greatly appreciated..
    Thanks
    JJ

    Hi Paul,
    Thanks for your comments.
    I achieved the clear contents by resetting, by taking input from your thoughts..
    form1.sub1.sub2.sub3.table_1.addDelete_Top.addDelete.deleteRow::click - (JavaScript, client)
    //Here is my code finally look like..
    //row 1, table_1 are also subforms
    for (var i=1;i<10;i++){
    var myRow = this.resolveNode("table_1.row1[" + i + "]");
    if(myRow.presence == "hidden"){
    i = i-1;
    var myRowDelete = this.resolveNode("table_1.row1[" + i + "]");
    if(i!=0){
    xfa.host.resetData(myRowDelete.somExpression);
    myRowDelete.presence = "hidden";
    break;
    if(i==9){
    xfa.host.resetData(myRow.somExpression);
    myRow.presence = "hidden";
    break;
    Thanks
    JJ

  • Is it possible to make an iphoto book that has all text on a page?  I want to have some pages with mostly text.

    Is it possible to make an iphoto book that has mostly text on some of the pages?  I would like to make a book that has more text than photos on some pages.

    Of course (at least in some themes - travel for sure) - have you looked at the available layouts?
    LN

  • Properties of a PDF that Affect Direct Text Copying to Other Programs?

    I am using a program that Acrobat Pro XI does not convert its files to (e.g. word). Therefore, I select & copy sentences from PDFs and paste them into this program. Most of the time, copying special characters like the greek letter psi from a PDF shows up as “Y” when I paste it into the other program. However, there are some PDFs that actually paste psi correctly.
    What’s interesting to note is that these different properties are observed in similar PDFs. For example, my professor posted lecture notes as PDFs: notes from lecture 4 allow me to copy&paste all special characters properly, while lecture 7 notes do not, even though they look very similar as documents.
    Can anybody think of any properties/settings that may be different between the two PDFs? Even if I cannot fix the problem, at the very least I might be able to predict which ones allow direct copying.
    Any help would be greatly appreciated.
    Note:  "Y" vs. "Psi" registration is independent of the program I paste into.  Word follows the exact same copying trend as my other other program

    Not sure why you cannot convert to WORD in AA XI. Just use File>Save As and select the WORD option.
    As to the psi, it may be that the font used in one of the files was different and you do not have it on your computer, so the copy used the closest version it could find. You can use ctrl-D to check the fonts in the system. Since you mentioned psi, do not expect the conversion of mathematics to WORD to be done well or at all. It may be the fonts used were from MathType and you would need the MathType fonts on your machine in that case. It would be a lot easier if we could look at the PDFs, but they may not be available for general posting. If you like, you could try a private message and setup to send the files by e-mail to review.

  • Need Javascript code for changing text field color

    Looking for a Javascript code to change the textfield background color and edge color in acrobat?  (without any xfa reference)

    The background color is the fillColor field property: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.705.html
    and the edge color is the strokeColor property: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.723.html

  • I added an add-on somewhere that affected all areas of my computer. I want to get rid of it but cannot find it. Any suggestions?

    The add-on made it possible for me to use a single click and have the same effect as a double click. I don't know where I got the add-on from, but I am 99.9% sure it was a Firefox add-on.

    Try [http://www.revouninstaller.com/revo_uninstaller_free_download.html Revouninstaller ]. It will display all installed programs including hidden ones. The ones that won't show up in Add/Remove Program.
    The link goes to the freeware version.
    It's the only uninstaller I use. Been using it for years.
    It won't operate on FF Extensions though. For that go into FF Extensions and search for "Add-ons Manager" It will list everything in FF.
    Good luck

  • I have created an editable PDF via Adobe Indesign. When I open the PDF in Adobe Acrobat Pro DC, is there a way to specify a font style? Or is there a way in InDesign to make sure when someone type in that text field it is a certain font?

    I need to make sure the text that is entered is a certain font to keep it continuous with the rest of the document. Thank you!

    To go into form editing mode, select "Prepare Form" in the right hand pane. You'll then get a toolbar along the top that contains the various form-related tools. The first thing to do is add a temporary button. You'll use this to determine the name of the font for use with the script as well as place the script that will change the font properties of the text fields. So create a button anywhere, double-click it to bring up the field properties dialog, and on the Actions tab add a JavaScript action to the Mouse Up event that is:
    // Mouse Up script for temporary button
    app.alert(event.target.textFont);
    On the Appearance tab, select the font that you want to use for the text fields. Once you've done that, close form editing mode and click the button. It will display a popup that will list the font name. This may be different than the name that appeared in the dropdown on the appearance tab, so write it down. For example, when I chose "Minion Pro" from the dropdown, the popup showed "MinionPro-Regular".
    The next step is to replace that Mouse Up script with the following:
    // Mouse Up script for temporary button
    // Change the font and font size for all text field in this document
    for (var i = 0; i < numFields; i++) {
        var f = getField(getNthFieldName(i));
        if (f.type === "text") {
            f.textFont = "MinionPro-Regular";
            f.textSize = 9;
    Replace "MinionPro-Regular" with the font name that you wrote down before and set the font size to whatever you want. Use 0 to specify a font size of "Auto".
    This script will change the font of all text fields to whatever you specify. When you've confirmed that the text fields are set up as you want, you can go ahead and delete or hide the button. If you think you'll be doing a lot of forms work, you can create custom tools in Acrobat to speed up this process, but this should get you started. InDesign won't let you specify a lot of field properties and actions, so you have to work this way, and using automation scripts is an accessible way to significantly speed up the process and avoid mistakes.

  • Text Field with javascript tags execute

    We have a form with multiple text fields on it for users to enter information. If a user puts in something like the following:
    <script type="text/javascript">window.location="http://www.oracle.com";</script>
    into a text field and submits the page, anytime that text field is called on a page, the javascript will execute and redirect the user to oracle.com. Obviously, there needs to be some encoding of all text fields, but I was surprised that this actually worked. What have people done to restrict this from happening? Do we write a PL/SQL process to run onSubmit to check all text fields?
    Thanks,
    Jon

    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/sec.htm#CHDGEEFC
    Tyler Muth
    http://tylermuth.wordpress.com
    [Applied Oracle Security: Developing Secure Database and Middleware Environments|http://www.amazon.com/gp/product/0071613706?ie=UTF8&tag=tylsblo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0071613706]

  • Creating password protected text fields

    Hello, I need to make a form that if a password is entered, all text fields are available to be filled out and if no password is entered, then only a few chosen text fields can be filled out. I have searched many places and have come close to the answer but have still fallen short of my goal.
    thank you

    Here is one example to look at...
    You can use this on a click of a button.
    //JavaScript
    var pWord = "AbCdEf" //set your password
    var requestpWord = xfa.host.response("Please enter your password.")
    if (pWord == requestpWord) {
    this.presence = "hidden"; //hide this button
    //write your code to enable all the text fields
    }else {
    //write your code to enable only fields tha you want.

Maybe you are looking for