Conditionally Required Fields

Basics -
Running LC ES 8.2 and Acrobat 9 Pro and using Acrobat for this form.
Novice/Beginner in JavaScripting as a whole, especially as pertains to PDFs
Situation -
Trying  to set up a form wherein a field is required if one option from a combo  box is selected and to either be optional or removed otherwise.
I've  been trying "if ... else" statements without any luck. The field  (AbortRchgSA/#8) is set as Visible and not required by default. The  combo box (Mode/#16) is a required field. My attempts have taken two  forms.
Form 1:
var f = this.getField("Mode").value;
if (f = SA)
{var g = this.getField("AbortRchgSA");
g.required = true;}
Form 2:
if (this.Field.Mode.value == SA)
this.getField(“AbortRchgSA”) = required;
else
this.removeField(“AbortRchgSA”);
Any and all help is welcome.

For the second script, rather than removing the field, you should hide it, since you may want it back. You're also using curly quotes, which will cause an error.
Try something like the following as the combo box's custom Validate script:
// Custom Validate script for combo box
(function () {
    var f = getField("AbortRchgSA");
    f.value = f.defaultValue;
    if (event.value === "SA") {
       f.display = display.visible;
       f.required = true;
    } else {
        f.display = display.hidden;
        f.required = false;

Similar Messages

  • Not able to create conditional required fields at Tcode CJ20N Proj Systems

    Hello experts,
    I have a requirement to create a few custom fields under custom enhancement tab in CJ20N transaction, and depending on a particular value for one of the fields, another set of fields need to be set to required. (If FIELD1 = 'Y', FIELD2 & FIELD3 should be set to required)
    My approaches..
    1. Assign a screen group to FIELD2 and FIELD3. If FIELD1 = 'Y' then LOOP AT SCREEN, and set screen-required = 1 for that specific screen group.
    Problem with this approach is that, if I select FIELD1 = 'Y' (hit space or enter -> sy-ucomm = TOGGLE), the fields are successfully set to required. However, now if at this point I go and change value for FIELD1 = 'X' (hit space or enter), FIELD2 and FIELD3 still remain set to required, and keep requesting value.
    2. Do not set any fields to required. Instead set it to an information message in PAI, informing user that this field requires a value when FIELD1 = 'Y' on TOGGLE and SAVE.
    Problem with this approach is that even though during TOGGLE event user is provided with an informational message, if the user directly decides to SAVE (no change for TOGGLE event), in this case the same message is displayed, and the project screen itself is closed. I do not think it would be ideal for the user to see the entire project close on SAVE everytime they miss a conditionally required field.
    I am just not sure at this point how to handle this at SAVE so that I can still have the same control as I would when TOGGLE event is triggered.
    Experts please help if you have come across such a situation!!! Your insight would be greatly appreciated!
    Edited by: akkinair on Dec 16, 2011 1:25 AM

    Please find below the response.
    1. Assign a screen group to FIELD2 and FIELD3. If FIELD1 = 'Y' then LOOP AT SCREEN, and set screen-required = 1 for that specific screen group.
    Problem with this approach is that, if I select FIELD1 = 'Y' (hit space or enter -> sy-ucomm = TOGGLE), the fields are successfully set to required. However, now if at this point I go and change value for FIELD1 = 'X' (hit space or enter), FIELD2 and FIELD3 still remain set to required, and keep requesting value.
    --> When FIELD1 chnage used module with additon CHAIN-REQUEST and check its value if it is to be set to optional by using loop at screen and set screen-required =0.*_
    2. Do not set any fields to required. Instead set it to an information message in PAI, informing user that this field requires a value when FIELD1 = 'Y' on TOGGLE and SAVE.
    Problem with this approach is that even though during TOGGLE event user is provided with an informational message, if the user directly decides to SAVE (no change for TOGGLE event), in this case the same message is displayed, and the project screen itself is closed. I do not think it would be ideal for the user to see the entire project close on SAVE everytime they miss a conditionally required field.
    --> Can you please clarify it.
    Thanks
    Nabehet

  • Conditional Required Fields

    Is it possible to have conditional required fields. As in if a certain box is selected, certain fields will become required. Take a look at this example if this needs clarification. In this example, the left 3 text boxes are required. If I check the middle checkbox, can I make it so the 3 text fields in the middle now become required as well. Furthermore, if I check off the 3rd check box (rightmost one), can I make all of the text boxes as required fields. Thanks!

    Hope You have the code on the check box change event, which decides the need of required or not.
    if(this.rawValue =='1')
    TextField1.mandatory = "error";
    TextField2.mandatory = "error";
    TextField3.mandatory = "error";
    Gender.mandatory = "error";
    Gender.border.edge.color.value = "225,0,0";
    else{
    TextField1.mandatory = "disabled";
    TextField2.mandatory = "disabled";
    TextField3.mandatory = "disabled";
    Gender.mandatory = "disabled";
    Gender.border.edge.color.value = "0,0,0";
    If you have facing any problem send me ur form to [email protected] if possible, If need sample give me ur email id so that i can post the form.
    RAGHU.

  • Acrobat Pro XI Conditionally Required Fields

    have developed a simple form in Acrobat Pro xi. Need an example of javescript and where it should be placed. Form has three fields named: SpouseName, SpouseDOB, SpouseGender. All three fields are set to Not Required. If an entry is made in SpouseName, want to set SpouseDOB and SpouseGender to required. The form has a submit button on it and I assume that the code should go on a action on the submit but not sure. Any type of simple example will be greatly appreciated!

    Use this code as the custom validation script of SpouseName:
    this.getField("SpouseDOB").required = (event.value!="");
    this.getField("SpouseGender").required = (event.value!="");

  • Conditionally required field

    I'm trying to make a field required if a specific combo box answer is chosen.  I looked at a recent post (http://forums.adobe.com/message/3617710#3617710) but wasn't able to figure out how to make it work.  Here's more info: the combo box name is "Reason for hire list".  One of the choices is "Project Related", which I gave an output value of "Project".  I'm trying to make the "Name of Special Project" field required if you choose "Project Related" in the "Reason for hire list" field.  I assumed that the code should be as follows for the "Special Project" field, based on that message I linked above, but it's not working:
    (function () {
        var f = getField("Reason for hire list");
        f.value = f.defaultValue;
        if (event.value === "Project") {
           f.display = display.visible;
           f.required = true;
        } else {
            f.display = display.hidden;
            f.required = false;
    I also tried the following, to no avail:
    (function () {
        var f = getField("Reason for hire list");
        f.value = f.defaultValue;
        if (event.value === "Project Related") {
           f.display = display.visible;
           f.required = true;
        } else {
            f.display = display.hidden;
            f.required = false;
    Could you help?  Thanks.

    In the "Special Project" field, in the Validate tab, in the Run custom validation script box.

  • Conditional Required Field

    I have two fields on a form, one which is optional, and one that should only become required if the optional field is populated by the user.  Is this s scripting project?

    "Project" is quite a stretch... It's basically a single line of code, to be used as the first field's custom validation script:
    this.getField("OtherField").required = (event.value!="");

  • Struts validator for two fields(conditional required)

    Have a Drop down and an input field.
    When user selects "Type 1" from drop down only then the input field is required. otherwise it's not a required field.
    Looking at the validator guide in struts maybe I have to create a new validator rule which should check if drop down value "Type 1". But not sure how to code to say that the input field is required here.
    How to do this?
    Thanks.

    Yes you have to check for drop down value "Type 1".
    when you hit on submit it goes to the validation function right ...
    there add a condition. Check if tpe 1 is selected , if so proceed validation the text box , else skip that validation and come out.

  • Can I make certain fields conditionally required?

    I am TOTALLY new to acrobat- just to put that out there first. I am wondering in acrobat (NOT formscentral or indesign) how to make certain fields required based off the answer of the previous required field.
    I.E  first required field- "is this a single application?" if so, do NOT make the next few fields required
    "is this a joint application?" if so, make the next rew fields required.
    Can I get some help with this?
    Thanks!

    What is commonly done is a button is used to initiate the email, using a "Submit a Form" action and specifying the email address of the recipient. The submit will fail if any fields that are marked as required are blank. In your case, you need to set the required property of certain fields conditionally, based on the sate of the form, and this will require a bit of scripting. It's not overly complicated though and you can get some help here.
    The Acrobat help document is a good place to start, though it won't help with JavaScript programming. A good resource is AcrobatUsers.com where there are a number of tutorials and other resources available about forms.
    Be aware that submitting form by email is often less reliable than expected, for many different reasons. A more reliable and secure approach is to set up the form to submit to a web server, but this involves even more expertise as it involves server-side programming and interacting with a PDF form. Emailing may seem sufficient for your needs, but be aware of the alternatives.

  • Bypass Required Field Validation when needed in PDF Dynamic Form

    I faced a tricky situation, where some fields are required, but we need to allow bypass required (mandatory) validation rule when saving the form, and require to fill such fields when submitting the form. In other words, provide flexible control when to turn On / Off this feature.
    I wanted to implement a flexible solution, and I will post my findings here. Appreciate your feedback for improvements.
    Steps:
    1. Mark rquired fields as required.
    2. Specify "Empty Message" as "This field cannot be left blank", or similar.
    3. Specify "Validation Script Message" as "This field must have a proper value before submit", or similar.
    4. Create a Global Form Level Variable something like "StopTotalValidation" and default as "1" means by default, Turn Off Validation for some cases.
    5. For the fields which require this type of control, add the script (to be defined later) on the "validate" event:
    myTools.validateForRequiredField(this);
    6. Create a Script Object "myTools" and add the following script:
    function initStringFunc() {
    //call this function on Document Initialize
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g,"");
    String.prototype.ltrim = function() {
        return this.replace(/^\s+/,"");
    String.prototype.rtrim = function() {
        return this.replace(/\s+$/,"");
    String.prototype.isEmpty = function() {
        return (this == null) || this.trim() == "";
    function setNodeProperty(theNode, theProperty, newValue) {
       if (theNode[theProperty] != newValue) {
            theNode[theProperty] = newValue; 
    function isNodePropertyEmpty(theNode, theProperty) {
        var result;
        if (theNode == null || theNode[theProperty] == null) {
            result = true;
        } else {
            result = theNode[theProperty].isEmpty();
        return result;
    function disableTotalValidation() {
        StopTotalValidation.value = "1";
    function enableTotalValidation() {
        StopTotalValidation.value = "0";
    function isTotalValidationOn() {
        return StopTotalValidation.value != "1";
    function isTotalValidationOff() {
        return StopTotalValidation.value == "1";
    const conRequired = "(required)";
    function validateForRequiredField(theFld) {
        // Bypass Required Field Validation when Global Validation is Off.
        var result=false;
        if (theFld) {
            if (theFld.mandatory && theFld.mandatory == "error") {
                if (myTools.isNodePropertyEmpty(theFld, "rawValue")) {
                    myTools.setNodeProperty(theFld, "rawValue", conRequired);
                if (isTotalValidationOn()) {
                    if (isNodePropertyEmpty(theFld, "rawValue") || theFld.rawValue.toLowerCase() == conRequired.toLowerCase()) {
                        result = false;
                    } else {
                        result = true;
                } else {
                    result = true;             
        } else {
            result = false;
        return result;
    7. Now, on the click of "Save" button call the function "disableTotalValidation()" and on the click of "Submit" button call the function "enableTotalValidation()".
    I have just finished implementing the above solution, and as per my initial testing, it is working fine.
    I will post this to my Google Docs workspace, and provide updates their.
    Tarek.

    Hi Tarek,
    I see what you mean in relation to clarity if you used the form variable approach. It was only a suggestion. Like so many things in LC, there is more than one way to finding a solution to a problem.
    The triple equal sign (===) is testing if the condition is equal, but to a higher standard. It is testing if the values are identical to each other. For example if you were testing if a textfield was empty, with Equality (==) you might have this:
    if (this.rawValue == null || this.rawValue == "") {
         // Some script
    If you use Identity (===) you can do the same thing with less script:
    if (this.rawValue === null) {
         // Some script
    It is also useful when testing the value of an object, but also the type (eg string, number, Boolean).
    Lastly, it can be used for non-identity (!==).
    In relation to createNode() etc, apart from John's blog, it is covered in the LC documents: http://www.adobe.com/support/documentation/en/livecycle/documentation.html. Look for the scripting guides and the guide to the XML Form Object Model.
    Good luck,
    Niall

  • Conditional Mandaotry field in Material Master (Suggestion Needed)

    Hi ,
    I am having a requirement where  i need to make a particular field to be mandatory for a certain condition in Material Master.
    Say for a Product Hierarchy i want to make Volume Rebate Group mandatory ( Sales Org 2 View).
    Please suggest the possible solutions for the same.
    No userexit is possible , Screen exit is also out of picture as i will not get the value of second variable -
    Thanks
    Rajiv

    Hi Rajiv,
    there is a user-exit that can be used .. MGA00001.
    We use it to make some plausibility checks before saving a material and also some additional authorization checks.
    <pre>FUNCTION EXIT_SAPLMGMU_001.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(WMARA) LIKE  MARA STRUCTURE  MARA
    *"     VALUE(WMARC) LIKE  MARC STRUCTURE  MARC
    *"     VALUE(WMARD) LIKE  MARD STRUCTURE  MARD
    *"     VALUE(WMBEW) LIKE  MBEW STRUCTURE  MBEW
    *"     VALUE(WMLGN) LIKE  MLGN STRUCTURE  MLGN
    *"     VALUE(WMLGT) LIKE  MLGT STRUCTURE  MLGT
    *"     VALUE(WMVKE) LIKE  MVKE STRUCTURE  MVKE
    *"     VALUE(WSTAT) LIKE  MGSTAT STRUCTURE  MGSTAT
    *"     VALUE(WMFHM) LIKE  MFHM STRUCTURE  MFHM
    *"     VALUE(WMPOP) LIKE  MPOP STRUCTURE  MPOP
    *"  TABLES
    *"      STEXT STRUCTURE  SHORT_DESC
    *"      SSTEUERTAB STRUCTURE  MG03STEUER
    *"      SSTEUMMTAB STRUCTURE  MG03STEUMM
    *"      WMEINH STRUCTURE  SMEINH
    *"      SMEAN_ME_TAB STRUCTURE  MEAN
    *"  CHANGING
    *"     VALUE(CMARA) LIKE  MARU STRUCTURE  MARU
    *"  EXCEPTIONS
    *"      APPLICATION_ERROR
      INCLUDE ZXMG0U02.
    ENDFUNCTION.</pre>
    Just prompt an error message in case the required field is not filled.
      MESSAGE ennn(xx) RAISING application_error.
    I am sure it will help to solve your problem.
    Best regards
    Ferdi

  • View Criteria non required field

    Hello,
    I have a view object with a viewCriteria with the following condition: No between no1_prm and no2_prm, the condition for required is optional and I checked ignore null values.
    The bind variables of the view object are not required.
    I made a page with a search form (af:query) but I want that even I complete only one field (no1_prm or no2_prm) to receive the result for that parameter. Now I receive error that the filed is required.
    How can I make :
    - when I complete one value for the parameter to receive exact value for that parameter
    - when I complete the two values for the parameters to receive all the numbers between the two parameters.
    Thank you in advance.

    I set only that condition : No between no1_prm and no2_prm with validation optional and ignore null values checked.
    The all view object where clause is :
    ( ( NR BETWEEN :nr_prm1 AND :nr_prm2 ) OR ( :nr_prm1 IS NULL AND :nr_prm2 IS NULL ) )
    I mention that in my page I must to have only : No label : input text for no1_prm - input text for no2_prm. If I complete only input text for no1_prm I receive the error for required field.
    Thank you.

  • Seem to have lost my required field option in Business Catalyst

    Hi there,
    I have set up a business catalyst form and formatted it but in the process have lost the required field functionality
    http://aom002.businesscatalyst.com/registration_copy.htm
    The form should not be able to be able to be submitted if the terms and conditions and other REQUIRED fields are not completed.
    At the moment none of the required fields need to be filled in and the form can be submitted.
    Any thoughts would be great.
    ciao
    Cathy

    Hi Matt,
    Sent youth wrong link.Here is the correct link with the formatting - the able unformatted form works fine but this formatted on let's you submit without completing required fields.
    Registration
    I have obviously lost some formatting.
    Any help would be great.
    ciao
    Cathy

  • Condition type field when Define Pricing Procedure Determination

    Hello Gurus,
        there is a condition type field when Define Pricing Procedure Determination. what does it mean ?
    Many thanks,
    Frank Zhang

    Here is are the details of various fields while configuring pricing procedure.
    A. STEP
    This indicates the number of step-in the procedure.
    B. COUNTER
    This is used to show a second ministep
    C. CONDITION TYPE
    This is the most important component in the pricing procedure. The rates are picked up from this element, on the basis of the properties described.
    D. DESCRIPTION
    This forms the description of the condition type.
    E. FROM
    This is used to define the progression of the calculation and range of subtotals
    F. TO
    This is used to define the progression of the calculation and range of subtotals
    G. MANUAL
    This function enables to allow the condition type to be entered manually also apart from automatic pickup.
    H. MANDATORY
    This function identifies the conditions that are mandatory in the pricing procedure. The sales price is a mandatory condition type.
    I. STATISTICS
    This can be used to represent the cost price of the material sold, generally used for study statistical impacts of price
    J. PRINT
    The activation of this function will enable the printing of the values and conditions to the document.
    K. SUBTOTAL
    A key is assigned from the drop down menu; this can be used by the system in other area like Sis for reporting purpose also
    L. REQUIRMENT KEY
    This function is used to assign a requirement to the condition type. This requirement can be used to exclude the system from accessing the condition type and trying to determine the value. This can be used to specify that the condition type should only be accessed if the customer has a low risk credit.
    M. ALTERNATE CALCULATION TYPE
    This function allows you use a formula as an alternative in finding the value of the condition type, instead of standard condition technique. this can be used to calculate complex tax structures.
    N. ALTERNATE CONDITION BASE VALUE.
    The alternative condition base value is a formula assigned to a condition type in order to promote an alternative base value for the calculation of a value.
    O. ACCOUNTS KEY
    The account keys form part of account determination. These keys are used here to define the posting of the revenue generated to respective account heads& to subsequent assignment to GL accounts.
    PR00- ERL
    K007/KA00- ERS.
    KF00- ERFu2026u2026u2026u2026.& so On.
    P. ACCRUAL KEY.
    The accrual keys form part of account determination. These keys are used here to define the posting of the revenue generated to respective account heads& to subsequent assignment to GL accounts and payment to respective parties.
    Kalpesh

  • How to conditionally encapsulate fields within ECC 6.0

    I'm interested in strategies to conditionally encapsulate fields within ECC 6.0.
    The requirement would be to mask specific fields (e.g. Vendor Name) within a particular data set (e.g. a particular Company Code) by default while allowing those fields to be visible by some users.  The key is that we do not want to mask these fields globally, nor do we want them masked for every user.  Even more important, we do not want to modify all the transactions and programs where these fields are available.
    I know one option is to add custom code at the Domain level of the fields.  We're currently investigating this further to see if it will satisfy all our needs and perform well.
    I'm looking for any other options we should explore, including 3rd party options.
    Thanks,
    ~Matt

    Alex Ayers wrote:Taking the example of the vendor master, i dont think retrcition on F_LFA1_AEN would really help. when a display transaction is used the protected fields are also shown. I understand it is a "no worry' on the complaiance front, but i suppose there could be a valid reason for not allowing users to display something (the operator can shed light on that)
    And from what i understand, the object doesnt get checked during the creation of master records too - its primarily to control the changes made on certain fields of the master record.
    and it needs a certain amount of effort to understand & check  the implications before starting with the filed group customizing
    >
    > For the benefit of Shekar there may be the opportunity to use transaction variants    
    thanks, Alex. This need could in all fairness end up with that.... a transaction variant
    > 1. Don't give access to the transaction if you can't trust users to use it properly
    > 2. Use a detective control to identify where users have changed things that they shouldn't have.
    Why do i feel an Auditor posted this????
    > Finally, using parameter ID's for this purpose generally will not work and should not be considered for security reasons
    100% agree with you

  • How to make a conditional required form item

    I'm working with an old version of Dreamweaver (CS3) and I'm trying to create a user information registration form. I've got a field for a phone number and then a select box for phone type. I'd like to include an option for a second number and type, but I don't want to make it required. However, if the user enters a number there, I want the type selection box to be a required item. I'm just using the provided spry validation widgets, but I can't find that option anywhere. Is it possible to make that selection box required based upon whether or not the user has entered a value in another field?
    Appreciate any help!
    Jeremy

    Dear sri,
    i want to make a required field thru personalization
    I appied following coditions:
    ========================================
    Trigger Event : WHEN-NEW-FORM-INSTANCE
    Trigger Object :
    Condition :
    ACTION:
    Property : ITEM
    PO_APPROVE.NOTE
    REQUIRED
    TRUE
    ========================================
    Trigger Event : WHEN-NEW-ITEM-INSTANCE
    Trigger Object : PO_APPROVE.WF_OK_BUTTON
    Condition : :PO_APPROVE.NOTE IS NULL
    ACTION:
    Message SHOW
    'NOTE is required field. Please Enter NOTE.'
    ==========================================
    But it is not working.
    Its urgent
    Please assist with coding.
    Thanks
    Pradhyumn Sharma

Maybe you are looking for

  • Skype 5: Skype can't connect

    I'm trying to log into Skype 5 but it says "Skype can't connect"... How do I fix that? Solved! Go to Solution.

  • Insertion into local table from remote table with contains clause

    Hi all, We are tasked to insert some rows into our database from another database. We tried to use DBLinks to link the 2 databases and were able to use Select statements to filter out the data that we need to insert into our database. These statement

  • Using SDO_UTIL.RECTIFY_GEOMETRY for 3d geometries

    A user reports the error "ORA-13199: the given geometry cannot be rectified" in the thread below: Geometry cannot be rectified and Siva Ravada responds with "The rectify_geometry function only works for 2D geometries, it does not work 3D geometries."

  • System Time +Calendar using Swing

    Hi I'm trying to create Swing Appliation that displays the System time.but i don't know how to display it on the window.I imported package from java.util.calendar.* but i dont know how to use it. Also how can i create Calendar with help swing appliat

  • Finder menu commands replaced by code?

    It's like some commands in Finder menus have been replaced by code. Seriously weird. For example, in the Edit menu Cut now reads ME1, Undo reads ME13, and such. Not all the commands have changed. This has only happened with Finder (so far as I can te