Adobe forms-checking that required fields are completed-Java Script

I have inserted two Java Scripts into my form--one for checking for required fields are completed, and then one for generating an email pulling a custom subject line, as shown below:
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
     var f= this.getField(this.getNthFieldName(i));
     if (f.type!="button" && f.required && f.display==display.visible) {
          if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
if (emptyFields.length>0) {
     app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
this.mailDoc({bUI:false,cTo:"[email protected],[email protected],[email protected]",cSubject:"Bugzilla Form for: "+this.getField("Bugzilla Title").value+" - "+this.getField("Bugzilla ID").value})
Issue: After the error window displays fields that have not been completed, when I click OK the email window displays.
QUESTION: How can I stop the email window from displaying until all fields are completed?
THANKS!

Thank you so much for your quick response (and thank you for all the code that I am reusing!) I have another issue now.Can you see why the following is occurring....
I placed else in and now it edits the required fields, but once they are completed, will not initiate the email prompt. Here's what I have now
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
     var f= this.getField(this.getNthFieldName(i));
     if (f.type!="button" && f.required && f.display==display.visible) {
          if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
if (emptyFields.length>0) {
     app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
elsethis.mailDoc({bUI:false,cTo:"[email protected],[email protected],[email protected]",cSubject:"Bugzilla Form for: "+this.getField("Bugzilla Title").value+" - "+this.getField("Bugzilla ID").value})

Similar Messages

  • Unable to save a form with missing required fields

    I have a form, with required fields, as part of the new hire process. I would like to make sure the user fills in the required fields before closing/saving the form.
    I have a custom script that highlights the missing required fields when the complete/validate button is clicked.
    This, however, doesn't stop the user from saving the form. As a result, we are getting incomplete forms returned.
    Is there a way to stop the user from saving the form until the required fields are filled ?
    Thanks in advance.
    Aditya

    I have a "validate" button that sets a flag (for workflow). This button will perform the check and highlight the missing fields.
    Once the user completes the form, he/she saves and emails the form. The reason for not having the email button is because not all users will have outlook and wouldn't want to go through the wizard.
    I understand your point but I need to know if there is some solid way of not allowing the users to return the form without completing the form.
    If I include an email button, the users can still save, by using the toolbar menu, and email the incomplete document.
    As we are planning to implement Digital Signatures, would it be possible to have the check in the presign event. Will this prevent the document fron being signed until the required fields are filled ?
    Thanks
    Aditya

  • I can't download Ikea 3D kitchen planner.  It's really frustrating - a message is appearing on my mac book pro that I ned to get info and check that various files are unlocked.  I've checked that all other requirements are fulfilled, still won't download

    I can't download Ikea 3D kitchen planner.  It's really frustrating - a message is appearing on my mac book pro that I ned to get info and check that various files are unlocked.  I've checked that all other requirements are fulfilled, still won't download.  Any help very gratefully received.  Thank you.

    Hi, I'm not really very good with computers and am having the same problems when trying to install the Ikea 3D kitchen planner, please could you take me through the steps?
    1. Download (save) the disk image file 2020PluginInstaller.dmg
    I double click on the link which says "Install 3D Planner"
    I agree to the t&cs
    A file downloads to my download folder called 2020PluginInstaller_IKEA.dmg
    2. Mount the disk image (open/run the downloaded file) if not mounted automatically
    I double click on the downloaded file
    3. Find the 2020PluginInstaller window (might be behind the window on top)
    A small window opens up with a lego brick called 2020PluginInstaller_IKEA.dmg and a folder called Internet plug ins.  I highlight the lego brick and do File, Get info and unlock it
    4. Drag the lego piece to the folder (if you do not have admin privileges you will be prompted to authenticate)
    I do this and put in a password to authenticate
    5. Restart the browser (it is not enough to close the browser window, you need to restart the browser
    application)
    I've tried restarting Safari, I've tried re-starting the computer
    6. Access the same link and you will now see the Start button and be able to start planning your room!"
    When I go back to the IKEA kitchen planner I don't see a start button, I just see the exact same screen as before prompting me to install the 3D planner
    Please can you help?

  • Check for required fields before locking subforms and submitting

    Hello,
    I have a 5-page form with many questions, to be completed by the original requestor and multiple approvers.  What I'm trying to do is have the original requestor's Submit button on p. 3 lock the input on the first three pages, but first check if all those fields have some content.  I currently have all the fields on pp. 1-3 set to "Required" in the object properties, but my script still locks them when there's is one empty one.  Here's what I have:
    //Lock portions of form
    Page1.access = "readOnly"
    Page2.access = "readOnly"
    Page3.access = "readOnly"
    //Save document, allow user to change name
    app.execMenuItem("SaveAs");
    //Submit via e-mail
    Submit_REAL.event__click.submit.target = "mailto:[email protected]" +
    "?subject=Subject text" +
    "&body=Message";
    Submit_REAL.execEvent("click");
    The automatic check for required fields happens after the pages get locked.  I would like the check to stop the process before it locks the pages.  Is there any way to check all at once that all "Required" fields on those pages have some content before allowing the script to proceed?  I know how to script it to manually check the 50 or so questions on those pages, but I would like to avoid that.  Thanks for any help.

    There are a few problems that I can see from the start. First, your code is going to pick up EVERY node that exists on these pages. Some of those nodes will not have a rawValue, and some will not have an actual name. As an example, you can take your code and create a text field to dump all of the names of the nodes that you get when you pull in all of the nodes this way. Here's an example:
    The result:
    Now, the question is, do you have a consistent naming convention for your fields that might be empty? That could be text fields, radio button lists, etc. For instance, I always prefix the names of objects in order to more easily keep track of what they are in scripts. Since I'm doing that, I can check the name of the field for tf, nf, rbl, cb, or whatever I have included to make sure that I'm checking an actual field before I check for things like rawValue.
    var nodeName = oNodes.item(nNodeCount).name;
    if (nodeName.indexOf("tf")>-1 || nodeName.indexOf("rbl") > -1 || /*check other field types*/) {
      //insert your code to check for empty answers here
    As for your line 7 issue. The syntax problem is that you've put extra parentheses in your if statement. Take out the parentheses that are just before and after the or "||".
    *This is my fourth attempt to reply. Something was going on with Adobe/Jive earlier, I suppose.

  • Alert user when saving PDF if required fields are empty/null

    Greetings,
    I've read a fair number of threads on this topic. I am not trying to force the user to stay in a field or otherwise be annoyed. I would just like to alert the user when they save the PDF if there are required fields that have not been filled out. The alert message would simply be a polite reminder to complete the form before sending.
    I'm using Acrobat XI Pro.
    1) Is the Other Tasks/Set Document Actions/Document Will Save the correct place to use a script in this case?
    2) Would the script need to check each required field by name? Or is there a way to reference all required fields in the document?
    3) I've seen some examples like this:
    f = getField(event.target.name)
    if (f.value.length == 0)
        f.setFocus()
        app.alert("This field is required. Please enter a value.")
    However it has some issues with respect to closing the alert dialog and so forth. Can anyone provide a sample script to get me started?
    Thanks!

    Exactly how you check a field for being empty depends on what type of field it is. For text fields, you should get the field's value as a string and compare it to an empty string, something like:
    var val = getField("Text1").valueAsString;
    if (val) {
        app.alert("Field is not empty");
    If there is a default value that needs to be changed, you would compare to the default value:
    var f = getField("Text1");
    var val = f.valueAsString;
    if (val !== f.defaultValue) {
        app.alert("Field value is OK");
    For check boxes and radio buttons, you'd compare to the string "Off", which means none in the group is selected.
    For dropdowns (combo boxes) and list boxes, there is normally one value selected, so you would have to get the value and check against the default value (or something else) to see if the field is properly filled in.
    You could place the script there, but I usually use a separate button that I encourage the user to click in order to check the field. The problem with using the Will Save event is you can't prevent the save from happening.
    The script can loop through all of the fields (and test all required ones), or you could set up an array of field names to check.

  • Adobe Forms - setting the "required" directive

    I am trying to create a form that requires all areas to be filled out prior to submitting.  The part I'm having trouble with is the drop down box.  I want it to show as blank or "Select One" initially, but force the recipient to select one of the options in the drop down list.
    Is there a way to do this using Actobat 8 Professional?

    You can alert the user if there are any empty fields in the form that are required.
    There are several earlier posts about this on this forum. Just search for "Validation" or "Required Fields".
    Here is one that might get you started:
    http://forums.adobe.com/message/3760854#3760854Re: Required Combo Box field with User option for custom text
    I hope this helps.

  • How to block the 'save' function when the required fields are not filled?

    Hello, Everyone
    I am new for this scripting. My question is:
    How to block the 'save' function when the required fields are not filled?
    I designed a PDF file with some required fields and I do not want the user to save the document until all required fields are filled. My idea is to write some scripts in Willsave method like:
    if (this.getField("Family Name").value == ""){
    app.alert('You should fill the Family Name field firstly!');
    But I do not think it works as finally the document is saved after all.
    Please help me on that!
    So much thanks.

    Dear Randybearwang,
    I am a Rocky myself and I know how though it is to establish some good codes. Since I created some forms with validation options myself I might have a code for you. The code also creates an alert box (Yes/no option) if the user chooses yes the form will be validatet, if he chooses "no" the alert window will be closed.If  everything is filled out correctly the form will be saved otherwise the textbox will be higlighted and gets focus.
    If you need further assistance , please let me know
    Have fun with the code.
    P.s I don´t know how to upload the "PDF" document. I wrote you an email, please get back to me if you still need the file.

  • Email submit button causing required error when all required fields are filled in

    It looks like if I have more than 1 instance of subform  added,  my email submit button triggers "..at least one required " error message when all required fields are filled-in.
    I toggle subforms between "visible" and "hidden (from layout)".  Any suggestion is appreciated.
    ralph

    The fields that are hidden should have the validate.nullTest property set to "disabled", something like;
    TextField1.validate.nullTest="disabled";

  • Help!  When I connect to itunes it tells me that required files are missing and please reinstall.  I have reinstalled and the same message appears.  Thanks. Windows XP

    Help!  I upgraded to 11 and it worked once. Now, when I connect to itunes it tells me that required files are missing and please reinstall.  I have reinstalled, I have deleted and reinstalled and the same message appears.  Thanks.
    Windows XP

    Meanwhile, I tried someone's suggestion to delete ITunes and Quicktime and reinstall both; still got the same mesage.

  • "iTunes can not run because some of the required fields are missing.  Please reinstall iTunes."  What the ****?!

    "iTunes can not run because some of the required fields are missing.  Please reinstall iTunes."  What the ****?  Please help me figure this out.  I already removed quicktime (as another thread suggested).  I can't get in!

    i get same error.
    I have uninstalled and reinstalled more times than i care to count. but still i get
    itunes cannot run because some of its required files are missing.

  • Is there any why to check that the reports are functioning well in Webanaly

    Hi Experts,
    is there any why to check that the reports are functioning well in Webanalysis?
    any Help in this issue ASAP is highly appreciated
    Kind Regards,
    Vam-c

    What do you mean by checking whether they are working?
    You can always open the report and see whether everything is working ;)
    Regards
    Celvin
    http://www.orahyplabs.com

  • Today I restore my phone, before I restored it I checked that my photos are saved on my icould, I did the backup and everything was back on my phone but not my photos! :( please help I need my photos back :|

    today I restore my phone, before I restored it I checked that my photos are saved on my icould, I did the backup and everything was back on my phone but not my photos! please help I need my photos back :|

    Hello purpleroses68
    To download any photos that were on your My Photos Stream, then you will need to have Photo Streamed turned on within your computer. Keep in mind that My Photos Stream only holds the last 30 days of photos and those will be the only one that will download. Check out the articles below for more information for the process and general information about getting your photos downloaded.
    Archive or make copies of your iCloud data
    http://support.apple.com/kb/ht4910
    iCloud: My Photo Stream FAQ
    http://support.apple.com/kb/ht4486
    Regards,
    -Norm G.

  • NSS4100 RAID DOES NOT START Please check that all components are present

    Hi, The NSS4100 storage system failed to start the raid10.
    The message is:
    Failed to start RAID
    Please check that all components are present
    All the disks are present as you can see in the attached image.The system has been restarted twice. Is there a possibility to start again the raid without losing data?
    Thank you,Dan

    Hi.
    I have exactly the same problem which is discribed first in this Thread.
    We have a NSS 4000.
    4 HDs - RAID 5
    SATA 2 was faulty an the RAID was degraded
    There was no problem with the data on the Volumes. I pulled the disk on SATA 2 (which was the one which no longer was in the RAID). Ich pushed it in again. Then on RAID site i clicked on 'Edit' and then on 'Add'. I thought the RAID would then synchronize the fourth HD and the status is going to be 'Running' and we are safe of one harddisk failiure.
    Log:
    2010-01-04 13:04:49 RAIDA : Rebuild Finished
    2010-01-04 13:04:46 RAIDA has failed.
    2010-01-04 13:04:46 RAIDA has suffered a drive failure.
    2010-01-04 11:27:15 RAIDA : Rebuild Started
    While the process was synchronizing i could access the data on the Volumes.
    But after 90 min the RAID was broken. No Access on the data - no shares. The Status is 'Stopped'. All 4 HDs are Online and the Health Status is 'Passed'
    If i click on Start:  "Failed to start raid. Please check that all components are present."
    I have no saved configuration because i thought that there will be no problem with this 'basic procedure' of a RAID device.
    Even if the HD is broken the RAID should be doing his job in 'Degraded' mode. Thats because i am using a RAID.
    So am i right that our data is gone because only one HD from a RAID 5 seems to be broken?

  • Form Features: Checking for required fields on scrolling or moving to the next page.

    Hi! I am developing a form which will be distributed to people using Adobe Reader without the JavaScript functionality. I have a form with about 20+ pages and each page has 4 required fields. I would like to make it easy for the users to show the errors then and there when they miss a require field, instead of having a generic "required field not filled" message at the end of the document. How do I do this without JavaScript? It would be better if the document jumps to the page where there is an empty "required" field.

    This isn't possible without using JavaScript.

  • Need help making digital signature field read only if required fields are null

    Using Adobe LiveCycle Designer, I have a digital signature field.  I want to prevent users from being able to digitally sign the pdf if any required fields in the pdf are null or blank.  I'm a newbie to scripting so any detailed help would be greatly appreciated.  The required fields in the pdf include radio buttons, check boxes, text field, etc.  I appreciate any help anyone can provide.
    Thanks

    Exactly how you check a field for being empty depends on what type of field it is. For text fields, you should get the field's value as a string and compare it to an empty string, something like:
    var val = getField("Text1").valueAsString;
    if (val) {
        app.alert("Field is not empty");
    If there is a default value that needs to be changed, you would compare to the default value:
    var f = getField("Text1");
    var val = f.valueAsString;
    if (val !== f.defaultValue) {
        app.alert("Field value is OK");
    For check boxes and radio buttons, you'd compare to the string "Off", which means none in the group is selected.
    For dropdowns (combo boxes) and list boxes, there is normally one value selected, so you would have to get the value and check against the default value (or something else) to see if the field is properly filled in.
    You could place the script there, but I usually use a separate button that I encourage the user to click in order to check the field. The problem with using the Will Save event is you can't prevent the save from happening.
    The script can loop through all of the fields (and test all required ones), or you could set up an array of field names to check.

Maybe you are looking for

  • Issue in new macro calculating values in time series in CVC

    Hi friends. I'm new in APO. I have a problem with a new macro in CVC which calls up a FM to calculate and store data. This new macro calculates the selected data in time series (TS) and e.g. we select 3 days to make calculation with this macro, the f

  • HOW TO READ  EMAIL  FROM ANY MESSAGE

    Hi all, Actually i want to retrieve email value from "TO" field in any message, in jsp page,is there anyway??? Thanks in advance..

  • Files from LR are not returned when saved, why?

    Hi, export files from Lightroom 5.3 CC to Photoshop CC, edit them and hit control /s but they don't return to Lightroom. They are saved in the catalogue.  Adobe agent suggested my error was to convert all my Raws to DNG, but this is common and it is

  • HT1338 Can't access my mac os side after installing win7

    I just installed windows 7 on my new mac using boot camp. I followed all the steps but after installing win7 there is no way I can access my mac os partition. I tried to reboot with the Alt/option key pressed but I am presented with a window asking m

  • Batch processing light levels...

    I make stop-motion animations using natural light. This results in a "flickering" effect due to the small differences in light in each still. I am able to balance the light levels in Photoshop for each still, but this is very time-consuming. I've hea