How to make a form field validate that it is the sum of the other two fields?

Hello

I'm creating a form, and I'd like one of the fields to validate by making sure that this field is the sum of the other two fields of the form.  Anyone have any ideas on how to go about it?  I know that I need to run a custom validation script, but I don't know where to start - I have never made one for before validation.

Thanks for any help!

OK, here's a sample script that I hope will clearly demonstrate the general approach. It is intended to be the validation script custom field that the user enters the value which is supposed to be equal to the sum of the other two.

Custom validation script

(function () {}

Get the value that the user entered

sVal var = event.value;

If it is empty, do nothing else

If (! sVal) {}

return;

}

Converts a string to a number

nVal = + sVal;

Get the values of the fields in the form of numbers

var v1 = + getField("text1").value;

var v2 = + getField("text2").value;

Add them together, rounded to two decimals, converting to the number

var sum = + util.printf ("%.2f", v1 + v2);

Compare the value of the sum of the other two fields

Change the user if they do not match

If (nVal! == $) {}

App.Alert ("the value entered does not equal to the sum of text1 and text2. Please correct. «, 3) ;

If you want the value entered was rejected, include the following

Event.RC = false;

}

})();

Replace "text1" and "text2" with real field names.

Tags: Acrobat

Similar Questions

  • How to make dynamic form fields updated?

    This is going to be an ugly post, just be careful! :)

    I have a form that retrieves his labels and text input field names dynamically from a database. Rather than having the form hardcoded, we are able to add new columns to a table and the form automatically adds the new labels and fields via CFQUERY.

    When the form is completed and submitted (post method), the database is supposed to be updated. However, because our names of input fields are populated through query, we can not write a query to update static when we add new elements of form.

    So, I have a solution to this (in my head), but I'm stuck in a bit of logic and can't get it in the code. I'm looking for a way to write FORM #. # fieldname # (here is where it gets ugly). Because the form sent by the post method, I find myself with a bunch of FORM.fieldname on my action page (and fieldname is generic for what are real variables).

    So here's how I am update:
    I have a table (let's call it table1) that contains a column of all the column names in the data table (table2). This table is used for query purposes only, no data is updated here of the form.
    I have a table1 request to call all the column names in table2.
    < cquery datasource = "exdb" name = "exname" >
    SELECT ColumnName
    FROM table1
    < / cfquery >
    Then I write the update query that will update the elements they are loop using CFOUTPUT:
    < CFOUTPUT QUERY = "exname" >
    < cfquery datasource = "exdb" name = "exupdate" >
    UPDATE table2
    SET #columnName # = #FORM. < columnName > #.
    WHERE itemID = #FORM.itemID #.

    It's my dilemma. As you can see, the cfoutput is a loop... So we will take the first element in the loop, call him 'name1 '. So our query update said SET name1 = #FORM.name1 #, and it will update the table with what was presented in the entry for name1 field. The cfoutput to loop again, this time it's of name2. SET name2 = #FORM.name2 #. Now, the form includes a hidden itemID to specify where the table should be updated, as you can see above. So, now that you see how it works, my problem is to get #FORM. < columnName > # FORM.name1, FORM.name2, etc.
    In Coldfusion, you would write #FORM.variable # to call a FORM element. However, given that the variable is not defined, and allows us to fill a request, we make SHAPE #. #variable # where #variable # must be resolved before #FORM. ___ #

    You are with me on this? This is very complex in the explanation, but if you need more information, I can provide more clearly. I would like to know what you think. Really, I have the solution, but to FORM #. # columnName # to solve is another problem. I think what I need is to understand the order of operations for this statement, so #columnName # resolves first.

    You'll want to use the scope structure notation when dealing with your form variables. The Form.SomeVar variable can also be written as ['SomeVar']. Using this syntax, you can do something like this:

    UPDATE table2
    SET #columnName # = #FORM [columnName] #.
    WHERE itemID = #FORM.itemID #.

    You can also look on the following to help optimize your code:
    (1) learn how to use - it could speed up your code a bit.
    (2) according to the DB that you use, you may be able to combine all of your UPDATE within 1 SQL commands block. This will allow to do all your actions with 1 DB connection database, instead of a bunch (works in MSSQL, Oracle or MySQL, not sure)

  • How to make a form field with Adobe Muse?

    Hello

    I hope you can help me guys, im trying to do a one page Web form field (this form is just to get a phone number, as the registration forms have a similar field) and the problem is with the widgets I can´t clear the field name and email... Is it possible to eliminate those?

    Thanks a lot for your help

    Hello

    I fear that it is not possible to do the same, in the field name and email are required.

  • How to make a form to fill out pdf to the next level?

    I created a form with fields. What I want to do now is download the form on my site that the form can be filled permanently by different people. Whenever a person could fill, it would stand on its own, not to be a collaborative effort. Wouldn't they be able to print or copy any part of the shape or text. Once they would fill out the form, I would like the information they capture to be saved (in the form itself if possible), so it could be picked up by our care. As a secondary issue, I would also like to put safety on the form, so he couldn't be copied/changed/print. Am a user of Adobe Acrobat for a long time but have not tried this before. I have the version Pro XI. Any help or insight that someone could provide would be much appreciated. Thank you.

    Since my question has not been answered by anyone, here's a new. What is the point of asking for help if nobody answers? Very frustrating. I have the classroom in a book, but I ask just a simple explanation of how the highest works.

    Hi jillb38584886,

    I provided you a few KB doc. for help, please refer to them: -.

    Publication of PDF forms on the web: https://helpx.adobe.com/acrobat/using/publishing-interactive-pdf-web-forms.html

    Securing PDF forms: using Acrobat | Securing PDF files with passwords

    Kind regards
    Nicos

  • How to make a video in Labview that synchronize with the case data?

    Hi guys,.

    I do a program which displays the case data from a satellite to different positions. (For example, to position more near the Sun, the temperature data are higher...)

    To make the most interesting façade, I add in a video of a satellite in orbit around the Earth. The video must synchronize with the data that I show.

    My satellite orbital time is 90 minutes = 5400 seconds. If I use the method of control of ring photo, I have to import 5820 photo frames in the control of ring image. My understanding is that every time that the user can import an image (correct me if I'm wrong). That would mean that I have to import the photos in 5400 times.

    Is there another way to do this? I don't want to waste my time on the import of so many images.

    Vanessa

    If it's a video you have, I would have a look at the incorporation of some sort of video player in the façade through ActiveX. It is not something I've ever tried, but it should be possible and will save you having to generate 5000 + images!

    There is a resource here on the use of VLC with LabVIEW: https://decibel.ni.com/content/docs/DOC-24114

    If you can embed a video player and can be driven through ActiveX, then you should be able to do what you want!

  • How to make a text field required at run time when the user clicks on the box?

    I had a form, there are several checkboxes fields and the text associated with the check boxes. If the use clicks on the checkbox then partner

    text fields should become mandatory. I tried the change event and the click event of the boxes. There is error in the onChnage event and I got some odd results in the click event on. Sometimes, if the user clicks the check box, then for the 1st time the field is not required, then the user onclicks the box and when the user clicks the check box for the second time the field becomes necessary, but if I turns off the option highlight the field and selects the field becomes necessary even if the user onchecks I am totally confused! To add that I have also written an incorrect code always I reached the goal? How it can be possible. I write the codes below, please help me because I am working under a deadline from the client.

    onChange event:

    var = this.boundItem (xfa.event.newText) newVal;
    if(newVal == 0)
    {
    xfa.resolveNode ("form1. Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1'). validate.nullTest = "disabled";
    }
    on the other
    {
    xfa.resolveNode ("form1. Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1'). validate.nullTest = 'error ';
    }*/

    For the onClick event:

    var a = xfa.resolveNode ("form1..") RawValue Subform0.Subform1.Subform9.Subform10.Table48.row2.CostItemRecovere d_OnlyEnergyCharges");
    App.Alert (a);
    if(a == 0)
    {
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck__L1_1").validate.nullTest = 'error ';
    }
    if(a == 1)
    {
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck__L1_1").validate.nullTest = "disabled";
    }

    Please help someone!

    Hello

    You may need this resolved at this point, but here are a few tips.

    An example of a loop in a dynamic array is here: Re: how to make invisible/visible or hidden columns with checkbox?

    You are usually not necessary to resolve the nodes, especially when the script object is in the same table as the target objects.

    For example if the table was not static your script could be simplified:

    if (this.rawValue == "1")  // this object is in Row2
    {
         Row4.ComplianceCheck_L1_1.mandatory= "error";
    ...
    }
    

    However because you will be to loop through all the rows in the table repeatable instances / then you need to resolve the nodes. Take a look at the example above.

    In your script, you have to Row8 Row4. I don't know if this is repeatable or just some of them. If we take Row4 as being repetitive, then you can apply the following to all repeatable lines.

    var vRow4 = Table48._Row4.count;
    console.println("Row4: " + vRow4); // You can delete this or comment it out after testing
    
    if (this.rawValue == "1")  // this object is in Row2
    {
         for (var i=0; i
    

    I have not tested, but it should be close to work.

    Good luck

    Niall

  • How to make a text field repeat several times?

    I have created a form with the name of a client in it - and the name is repeated at the top of each page.  How to make a text field repeat several times? Thank you!

    Make sure that all fields have the same name (LastName FirstName, MiddleName,), then set the binding in the overall binding tab.

    Paul

  • How to make a form with report and a form of inclusion in the same page?

    Hey, guys:

    I was wondering if you could have any link or examples to show how to make a form with report and a form of inclusion in the same page, these two forms are related to the same table. Our customer wants that a user can add a new row to the table in a form and see all lines created by this user in a report, the report should provide link change as well. the problem is: whenever I inserted a new line or change a line or delete a line, and submitted and return to this page, all hidden elements lost their values, this report is empty, and some display only items also lost their values. Could someone give me any suggestions?

    Thank you very much!

    Sam

    So, the problem is essentially with page elements lose their session state values when re-loading of the page. How do you define values for the elements of the hidden page? You have default values defined for those? They are based on the database column? What is the "Source" parameter for these items on the page? It is set to "Always, replace any value in session state"? You have any process of 'Empty the Cache', which is reset these values to null element?

    What is your version of the Apex?

    I would recommend that you have installed for example in apex.oracle.com. This would help to better understand the issue.

    Published by: jaouad khalifi on 13 December 2012 22:11

  • How to make uneditable Date field in ADF

    Hello

    I use Jdev 11.1.1.7.1.

    In the fragment, I added the DATE of the ENTRY component. How to make uneditable date field. He should just take the input value of the grille.

    Kindly advice me.

    Thank you

    Swathi

    Your date. MinValue must be like this:

    
                
                
                  
              
    
  • How to make a link in textflow that send parameters to a function?

    How to make a link in textflow that send parameters to a function?

    In the examples included with the weekly builds, there is an example of CustomLinkEventHandler.as.  Passing parameters would be in the CustomClickHandler function.  You can set the parameters to the LinkElement that user using the setStyle API styles.

    Hope that helps,

    Richard

  • How to make a required field in OAFramework

    How to make a required field in OAFramework when running? Please explain in detail if possible.

    Thank you
    Kumar

    Get the handle to the bean by using the following Code

    Bean = webBean.findIndexedChildRecursive ("");
    If (bean! = null & )
    {
    bean.setRequired (true);
    }

  • Simple question - how to make a readonly field

    Simple question - how to make a readonly field

    Hi DougBlincoe!

    I think you're looking for this:

    1. create the element. See "creating a Page level item.

    2. navigate to the appropriate page definition:

    Go to the Home Page of the database.

    Click the icon of the Application Builder.

    Select an application.

    Select a page.

    The definition of Page appears.

    3. under items, select the name of the element.

    The attributes for the element page.

    4. to display an item under certain conditions:

    Scroll up to Conditions.

    Make a selection in the list Type of Condition.

    Enter an expression in the fields provided.

    * 5. To make an element read-only: *.

    Scroll to display playback settings.

    Make a selection in the playlist only Type of Condition.

    Enter an expression in the fields provided.

    Click on apply changes.

    Here, you will get more information about this:

    # Create the item. See ["Creating a level of Page element" | http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25309/bldapp.htm#BCEFHBHG].
    # Navigate to the appropriate page definition:
    # Go to the Home Page of the database.
    # Click the icon of the Application Builder.
    # Select an application.
    # Select a page. ------------------Definition of Page appears.
    # Under items, select the name of the element. ------------------Page attributes for the element.
    # To display an item under certain conditions:
    # Conditions scroll.
    # Make a selection in the list Type of Condition.
    # Enter an expression in the fields provided.
    # To make a read-only element:
    # Scroll the display reading settings.
    # Make a selection in the playlist only Type of Condition.
    # Enter an expression in the fields provided.
    # Click on apply changes.

    Here, you can read more information about this:

    http://download.Oracle.com/docs/CD/B25329_01/doc/AppDev.102/b25309/bldapp.htm#sthref805

    I hope this helps!

  • How to make a video DVD of myself I use the webcam for laptop?

    How to make a video DVD of myself I use the webcam for laptop? I never did a video before, and I am a teacher who wants to put my sessions on DVD now. How and what do I do?
    Thanks in advance.

    Hi Sdashe,

    You need to browse for some third-party applications that could support the web cam video, and you can use windows media center media player to burn DVD.

    http://Windows.Microsoft.com/en-us/Windows-Vista/burn-a-CD-or-DVD-in-Windows-Media-Center

    http://Windows.Microsoft.com/en-us/Windows-Vista/burn-a-CD-or-DVD-in-Windows-Media-Player

    Bindu S - Microsoft Support
    Visit our Microsoft answers feedback Forum and let us know what you think

  • My panels disappeared.  How to make a comeback?  (I all checked, including the histogram, layers, actions and adjustments)

    My panels disappeared.  How to make a comeback?  (I all checked, including the histogram, layers, actions and adjustments)

    Hello madeline,

    Please check that you have selected the correct "essentials" workspace, if you already correct then try to restore Photoshop preferences to default.

    Steps to follow:

    To re-create the Photoshop preferences files, start the application while pressing Ctrl + Alt + Shift (Windows) or command + Option + shift (Mac OS). Then, click Yes to the message, "Delete the Adobe Photoshop settings file?"

    Let us know if that helps.

    Kind regards

    ~ Mohit

  • How can I find and close programs that run in the background of my computer?

    How can I find and close programs that run in the background of my computer...

    From Internet Explorer

    Original title: battery

    How can I find and close programs that run in the background of my computer...

    From Internet Explorer

    Original title: battery

    The less you have to run all the time, most things you want to run will perform:

    Use Autoruns to understand this all starts when your computer's / when you log in.  Look for whatever it is you do not know using Google (or ask here.)  You can hopefully figure out if there are things from when your computer does (or connect) you don't not need and then configure them (through their own built-in mechanisms is the preferred method) so they do not - start using your resources without reason.

    You can download and use Process Explorer to see exactly what is taking your time processor/CPU and memory.  This can help you to identify applications that you might want to consider alternatives for and get rid of all together.

Maybe you are looking for

  • Installation fails with error code 1603

    [The update by the moderator topic title should be more descriptive. [Was: "Please help me"] I use Skype every day to talk to my friends and he says I need to update some time ago but it does not, but I thought it wouldn't matter and I could still us

  • Re: Where to find Win XP drivers for Satellite 2410 404

    I have a Toshiba Satellite, but I don't remember what type it is.I have the serial number and production code that is: -. MOD: PS241e-5g7u9-had I had a hard drive failure and I have now re-installed XP but I lost the driver disk,I need to know what d

  • Portege S100 - fan runs constantly

    Hello I have been using my portege s100 for a year now and I must say that I'm not really happy. The fan runs constantly, even after the update of the BIOS. Does not stop a second, everything I put in power management. It's very disappointing, becaus

  • Smart Update slows U310

    Hi you guys at Lenovo. Software/installation of smart update on my U310 consumes a lot of time to treatment (+ 30, 40%) at the start of this ultrabook and it remains in memory all the time until I finish this process.Can anyboy explain this and it is

  • How to print an e-mail without printing the side panels and the folder list?

    Original title: print an e-mail How to print an e-mail without printing the side panels and the folder list?  It also prints a part of the message that the sides take up much space