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

Hi there,
I am creating a form, and I would like one of the fields to validate by making sure that this field is the sum of two other fields in the form.  Does anyone have any ideas on how to go about this?  I know I'll need to run a custom validation script, but I'm not sure where to begin - I've never done one for validation before.
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 custom Validate script of the field that the user enters that value that is supposed to be equal to the sum of the two others.
// Custom Validate script
(function () {
    // Get the value that the user entered
    var sVal = event.value;
    // If it is blank, do nothing else
    if (!sVal) {
        return;
    // Convert string to a number
    nVal = +sVal;
    // Get the values of the fields, as numbers
    var v1 = +getField("text1").value;
    var v2 = +getField("text2").value;
    // Add them together, rounding to two decimal places, converting to number
    var sum = +util.printf("%.2f", v1 + v2);
    // Compare entered value to the sum of the other two fields
    // Alter the user if they do not match
    if (nVal !== sum) {
        app.alert("The value you entered does not equal the sum of text1 and text2. Please correct.", 3);
        // If you want the entered value rejected, include the following
        event.rc = false;
Replace "text1" and "text2" with the actual field names.

Similar Messages

  • How do I make my form (list/menu) items open in the same window (self).

    Hello, the kind, brilliant people on this forum have always been able to help me in the past, so I thought I'd give it a try today. Items in a form (list/menu) that I've created are opening in a blank window (pop-up) when clicked. I would like them to open in "self" mode so that pop up blockers on various computers don't become a challenge for site visitors. Can anyone please tell me how I could make that adjustment? I selected the entire form "red dotted line" around the list and changed the "target" in the properties menu to "self". Then I selected everything on the page and still not correct. I am inserting the code below. Any assistance to get me on the right track would be GREATLY appreciated!! BTW I also made the form a library item (just in case that fact is needed). Also if you need to see the actual link it is http://www.graphicmechanic.com/DEKALBCOUNTY/index.html. The "I WANT TO" list is the part I'm referring to.
    CODE BELOW:
    <form action="" method="post" name="form1" target="_self" class="style26" id="form1">
                       <a href="#" target="_self"><span class="style26">
                       <label FOR="iwantto">I WANT TO:</label>
                       <br />
                        <img src="../images/5x5.gif" alt="layout graphic" width="5" height="5" /><br />
                        <select name="iwantto" id="iwantto" class="style55" onchange="MM_jumpMenu('window.open()',this,0)">
                          <option value="http://web.co.dekalb.ga.us/voter/#">REGISTER TO VOTE</option>
                          <option value="https://govaffiliate.ezgov.com/ezutility/index.jsp?agency=3411">PAY MY WATER BILL</option>
                          <option value="../humanserv/hs-osa-facilities.html">FIND A SENIOR CENTER</option>
                          <option value="../humanserv/hs-lou-walker.html">GET INFO ABOUT LOU WALKER CENTER</option>
                          <option value="http://www.dekalbstatecourt.net/">FILE A RESTRAINING ORDER</option>
                          <option value="http://www.dekalbcountyanimalservices.com/">REPORT A LOOSE DOG</option>
                          <option value="http://web.co.dekalb.ga.us/courts/recorders/payment.asp">GET TRAFFIC CITATION INFO</option>
                          <option value="http://web.co.dekalb.ga.us/courts/probate/pistol.htm">APPLY FOR A PISTOL LICENSE</option>
                          <option value="http://web.co.dekalb.ga.us/courts/probate/marriage.htm">GET A MARRIAGE LICENSE</option>
                          <option value="http://www.co.dekalb.ga.us/dekalbflic/Centers.htm#service">FILE FOR A DIVORCE</option>
                          <option value="http://www.co.dekalb.ga.us/superior/index.htm">GET INFORMATION ABOUT JURY DUTY</option>
                          <option value="http://web.co.dekalb.ga.us/taxcommissioner/search.asp">PAY MY TAXES</option>
                        </select>
                       </span>
                       </a>
    </form>

    Looks like it still isn't working. When I removed those items the drop down menu stopped working as well. I went ahead and posted yours as the correct answer. I'm convinced it's my skill level. i'm gonna do some javascript searches to see where the js code should go, it's very confusing to me. Here is that code in case anything sticks out to you or anyone else.
    <link href="../cssfiles/lbistyles.css" rel="stylesheet" type="text/css"/>
    <form action="" method="" name="form1" class="style26" id="form1">
                     <span class="style26">
                       <label FOR="iwantto">I WANT TO:</label>
                       <br />
                        <img src="../images/5x5.gif" alt="layout graphic" width="5" height="5" /><br />
                        <select name="iwantto" id="iwantto" class="style55">
                        <option value="#" onClick="MM_goToURL('self','http://web.co.dekalb.ga.us/voter');return document.MM_returnValue">REGISTER TO VOTE</option>
                          <option value="https://govaffiliate.ezgov.com/ezutility/index.jsp?agency=3411">PAY MY WATER BILL</option>
                          <option value="../humanserv/hs-osa-facilities.html">FIND A SENIOR CENTER</option>
                          <option value="../humanserv/hs-lou-walker.html">GET INFO ABOUT LOU WALKER CENTER</option>
                          <option value="http://www.dekalbstatecourt.net/">FILE A RESTRAINING ORDER</option>
                          <option value="http://www.dekalbcountyanimalservices.com/">REPORT A LOOSE DOG</option>
                          <option value="http://web.co.dekalb.ga.us/courts/recorders/payment.asp">GET TRAFFIC CITATION INFO</option>
                          <option value="http://web.co.dekalb.ga.us/courts/probate/pistol.htm">APPLY FOR A PISTOL LICENSE</option>
                          <option value="http://web.co.dekalb.ga.us/courts/probate/marriage.htm">GET A MARRIAGE LICENSE</option>
                          <option value="http://www.co.dekalb.ga.us/dekalbflic/Centers.htm#service">FILE FOR A DIVORCE</option>
                          <option value="http://www.co.dekalb.ga.us/superior/index.htm">GET INFORMATION ABOUT JURY DUTY</option>
                          <option value="http://web.co.dekalb.ga.us/taxcommissioner/search.asp">PAY MY TAXES</option>
                        </select>
                       </span>
                       </a>
    </form>

  • How do I make my text field automatically upper case?

    How do I make my text field in a form automatically upper case?

    Use the following as the text field's custom Keystroke JavaScript (choose a Format type of Custom):
    // Keystroke script for text field
    event.change = event.change.toUpperCase();

  • Interactive PDF form on Android, can I make a form field to open camera and use photo in field?

    If I have an interactive PDF form on Android, is there any way to make a form field that will open the camera and insert the photo in the field?

    One alternative would be to create a web form in FormsCentral and use the attachment feature.

  • I paid for exportpdf and everytime i try to use tool on pdf, it asks me to subscribe. i have to log into website EVERY time. not acceptable.  how can i export only form fields that were filled in?

    i paid for exportpdf and every time i try to use tool on pdf, it asks me to subscribe. i have to log into website EVERY time. not acceptable. Some forms can't be saved so having to log in and only use webtool to upload a saved pdf won't work.
    as well, how can i export only form fields that were filled in if I can get pdf to save to computer?

    Hi kstine,
    I can see why that would be frustrating! Have you tried selecting Stayed Signed In underneath the Adobe ID and Password boxes when you try to log in?
    What did you use to create the PDF form? If you used FormsCentral, form data is saved to your online FormsCentral account. If you have Acrobat, you can export form data as described  here: Adobe Acrobat X Pro * Manage form data files
    Best,
    Sara

  • How can I make a form show complex composite data?

    How can I make a form show complex composite data?
    We would like a form to display the following information:
    Employee Names as the columns, 1 row for each calendar day, and each item in the block containing the total sales amount (and other information) for that employee for that day.
    This would require the block to function as a (composite) crosstab report.
    Here is an example:
    We have employees: Jane, John, Jim, and Janice
    We would like to see their total sales for the following days: 5/1 .. 5/5
    Jane John Jim Janice
    5/1 50 8 10 3 30 5 20 7
    5/2 40 7 60 8 10 2 30 4
    5/3 20 3 50 8 70 9 50 9
    5/4 51 8 40 7 40 8 50 8
    5/5 10 1 20 2 90 10 10 2
    We have a table with records of each day, for each employee, and their sales for that day.
    There is a possibility our list of employees can change as well as the number of days.
    Anyone tried doing anything like this with a form? We don't want to just embed a report because we would like to include other data as well besides what is mentioned above and we would like them to be able to change some of that data. Thanks in advance for any help.
    null

    I have a VERY similar problem where I want to have this matrix on the form with six days worth of data (three columns for each day) for my data table. I have done as Momen has suggested and created a view (using SQLPLUS):
    create table weekdays (weekday varchar2(3), date_x date);
    drop view employee_absences_v;
    create view employee_absences_v as
    select weekday,
    absence_date,
    hours,
    absence_code_lvid,
    adjustment_status_lvid
    from employee_absences ea, weekdays wd;
    that hopefully provides a row for each day of the week for my data table. The view is created OK but I'm not sure how to get it into the form properly. Also, I am using the form to CREATE rows in the data table not just SELECT and DISPLAY and there may or may not be a row of data for a corresponding day which is going to be a problem for me using this view method, I think. Let me know how this goes and if you get your form to work and how? Momen, your method appeals to me but it's not 100% clear how to get it to work in a form?
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Tina Radosta ():
    We tried to create the view (not with Designer because we don't have that). We were not successful in creating a view with a matrix. We would greatly appreciate your help.
    Thanks in advance,
    Tina<HR></BLOCKQUOTE>
    null

  • How can I make my form be a certified document?

    Hi all,
    In my form, I want to export xml by using the script "Reference_Syntax.exportData( [ STRING param1 [, BOOLEAN param2 ] ])",
    for example, xfa.host.exportData("filename.xml",0).
    However, it is invalid. 
    It says that "This parameter1 is only valid on certified documents where the user has sufficient
    permissions".
    But how can I make my form be a certified document, or how can I get the sufficient permissions?
    Script "xfa.host.exportData("",0)" can be valid, but what I need is specifying the location and file name so that users can export xml just by clicking the button.
    Can I achieve this function?
    Waiting for your reply, thanks a lot!
    Ellie

    Please take a look at this discussion. Also, are your end users using Adobe Reader? If so, your document must be Reader Enabled withed LiveCycle RE to use the import / export xml functionality.

  • How we create dynamic add form field in web form

    How we create dynamic add form field in web form?

    Hi,
    Thanks for reply.
    I need to create a form in which "add more" input field dynamically. For
    example sometime we need field on or more. Please look at the demo, I need
    to create form as per demo in business catalyst:
    http://www.openjs.com/scripts/examples/addfield.php

  • Can you suggest how I can make only "salesperson" field mandatory?????

    Hi gurus,
    I want to make the field "Salesperson" in the Communication tab in the PO header mandatory.
    When I set the field selection accordingly(field "salesperson" as required entry), other fields such as your reference, our reference, telephone number becomes mandatory.
    can you suggest how I can make only "salesperson" field mandatory without making related fields mandatory?????
    Regards
    Sara

    Hi,
    Go to spro->MM->purchasing->PO->Define screen out at document -> select NBF ->Reference data, header->set field Reference, salesperson etc. as mandatory.
    reward full point if resolve,
    Regards,
    Chetan.

  • How can i make PO number field as a mandatery in sales order

    Hi Friends,
    can any one help me for the following requirement
    how can i make PO number field as a mandatery in sales order
    Thanks
    Nitchel

    Hi
    You have to include the "Purchase Order" field in the Incompletion list.
    Purchase order field is a Header data in the Sales order.
    So you have to create an Incompletion Procedure for Sales document Header.
    There include the field "Purchase order" field, assign the "Status group" to it.
    You may activate the error/warning check box.
    Assign the Incompletion Procedure to your Sales document type.
    Go to Sales document type VOV8 and activate the "Incompletion message" field so that without entering PO number you can not proceed.
    Now whenever you will create an order (using the order type where you have assigned the procedure), you have to fill up the PO field or else you can proceed.

  • How do i make a form that will tell me the difference between 2 figures?

    how do i make a form that will tell me the difference between 2 figures? ie: the jan. value of account is 32,010 and feb value is 34,013 and march value is 31,089 i would like it to tell me the difference automatically... whichever it is bigger or less... i am sure that this is possible... but i am a complete newby to all of this and could use some help...
    jan = 34,013
    feb = 34,013
    march = 31,089
    etc...
    etc...

    panahead wrote:
    i guess what i am trying to make is a form that will automatically calculate the difference in my investment account each month... and sometimes it goes up and sometimes it goes down... but having the difference calculated for me (without the possibility of me making a mathematical mistake) and then also giving me the percentage would be what i am looking for....
    Numbers will do the calculations, but it doesn't read minds.
    The formulas shown in my previous post assume a table arranged like the example below:
    The results in the bottom three rows (Apr, May and Jun) are correct for the simple formulas given and for the data entered in the Amount column as the empty cells are evaluated as containing zero. In practice, you would want a formula that suppressed the calculation until something was entered in that row of the Amount column. That's easy enough to add, should you think doing so will be useful.
    But it won't make Numbers read your mind.
    Regards,
    Barry

  • How to make a form dynamic so that it displays different logos at runtime

    I am working on some assignment wherein I would like to make a form dynamic so that in it's designated image holder it displays different logos/pictures at run time? First of all is there such a possibility?? I am still very new to this forum and also trying to understand the logic/bindings/heirarchy etc. in LCD. Any input would be highly appreciated.
    Thanks in advance

    LC 7 or 8 does not help load logs at runtime. However you can associate all your logs at design time and control their visibility property based on the events. This may help fulfill the requirements you have to an extent however adding number of images at design time will increase the size of the template.

  • How do I get PDF forms to export to excel in the desired order?

    How do I get PDF forms to export to excel in the desired order?
    Here is what I have done:
    As taken from another post:
    Choose Forms > Manage Form Data > Merge Data Files Into Spreadsheet.
    In the Export Data From Multiple Forms dialog box, click Add Files.
    In the Select file Containing Form Data dialog box, select a file format option in File Of Type option (Acrobat Form Data Files or All Files). Then locate the form files that you want to merge into the spreadsheet, select them, and click Select.
    Repeat the previous step to add form data files that are in other locations, as needed.
    Click Export. Then select a folder and filename for the spreadsheet, and click Save.
    In the Export Progress dialog box, click either View File Now to open the spreadsheet file or Close Dialog to return to Acrobat."
         The problem now is that Adobe populates Excel in ABC order of the form, based off of the name of each box in the form. For example, if my form has three text boxes, named A, B, and C, then Adobe will export to Excel as such:
    Row 1 =         A                              B                              C
    Row 2 =         data entered             data entered              data entered
    where 'data entered' is whatever the user typed into the form boxes. But what if I want a different order for exporting, and I don't want to rename my text boxes? What if I want:
    Row 1 =         C                              B                              A
    Row 2 =         data entered             data entered              data entered   ?
    Is there a way to do this in acrobat x or xi?
    Thanks

    I don't have time to test right now, but there was a change with Acrobat 10 where it exports according to the tab order, which you may have to set manually, so give that a shot. Otherwise, you'll have to process the file after it's exported if you need the fields in a particular order. This wouldn't be too difficult to do with something like a VBS or JS script in Windows.

  • How do I make one account's home folder visible to the other?

    How do I make one account's home folder visible to the other? Also, when I begin to delete an account, it asks if I want to either delete its home folder, keep it in the users folder, or save it in a disk image. I want to be able to see it from my remaining account once I delete it, so if I leave it in the users folder, would I be able to see all the files (right now I can't

    Use terminal to add ACL to the account,
    at the prompt:
    sudo chmod -R +a "<user> allow list,addfile,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr, writeextattr,readsecurity,file_inherit,directoryinherit" /User/<user_name> #yep, all that goes on one line!#
    #Replace <user> with the user name that you want to have file/folder privileges#
    #Replace <user_name> with the account you want to process#
    example:
    sudo chmod -R +a "sue allow list,add_file, .... deletechild,readsecurity,file_inherit,directoryinherit
    /User/joe
    #sue now gets full access to joe's files and folders#
    to remove:
    sudo chmod -R -a "sue allow list,add_file, .... deletechild,readsecurity,file_inherit,directoryinherit
    /User/joe
    You can add as many users as you want! Just lather, rinse repeat. That is how I share my itunes
    directory with the ones I want to share it with.
    That's the simplest way. ACL permissions overrule posix permissions.

  • How do I make a JTable's header sorting actually change the actual table?

    How do I make a JTable's header sorting actually change the actual table?
    Currently, I'm using
    table.setAutoCreateRowSorter(true);to allow the user to sort the table.
    However, I want to be able to load something based on the selected row's index. The problem is that when the table is rearranged, the change appears to only be local, in other words, the actual table isn't changing.
    For instance:
    index 0 "A"
    index 1 "B"
    index 2 "C"
    Sorted in reverse gives me
    "C"
    "B"
    "A"
    But C is still index 2 (instead of 0).
    Thanks in advance.

    Cross posted and answered in the Swing forum.
    [http://forums.sun.com/thread.jspa?threadID=5353865]
    I see this is not your first incidence of cross posting. In future, please post a question once only.
    db

Maybe you are looking for