Required fields based on multiple conditions

rss

Posted by VGrutle - Feb 22 ’17 at 03:42

Hi,

I have reviewed the blogpost (http://formsdesigner.blogspot.no/2014/07/how-to-conditionally-hide-disable-make.html) about conditionally setting mandatory fields. As i understand this code only accommodate for one condition.

In my case i have one lookup field (Case type) and one Choise field (status - radio button) that shall define which fields needs to be mandatory.

Any help is appriciated!

Thanks!

 

 

 

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 9 months 26 days
    #1 by Dmitry Kozlov Feb 27 ’17 at 03:57

    Hi,

    Then you just need to use a complex condition like that:

    fd.onsubmit(function () {
        if (fd.field('Field1').value() == 'X' && 
            fd.field('Field12).value() == 'Y') {
            if (!fd.field('DueDate').value()) {
                alert('Please, fill in the Due Date field.');
                return false;
            }
        }
    
        return true;
    });
    
  • VGrutle
    Member
    Member for: 2 years 4 months 24 days
    #2 by VGrutle Feb 27 ’17 at 03:21

    Thanks! But unfortenately this did not work out for me.

    How do I embed this into the code given in the example?

    function setRequiredFields() { if (fd.field('AssignedTo').value().dictionaryEntries.length != 0) { // Add asterisks fd.field('DueDate').titleRequired(true); } else { // Remove asterisks fd.field('DueDate').titleRequired(false); } } // Calling setRequiredFields when the user changes the assignment fd.field('AssignedTo').change(setRequiredFields); // Calling setRequiredFields on form loading setRequiredFields(); // Custom validation fd.onsubmit(function () { if (fd.field('AssignedTo').value().dictionaryEntries.length != 0) { if (!fd.field('DueDate').value()) { alert('Please, fill in the Due Date field.'); return false; } } return true; });

     

     

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 9 months 26 days
    #3 by Dmitry Kozlov Feb 28 ’17 at 03:01

    [#2]: Could you send the detailed description of your case (which fields become mandatory based on what choice) and a screenshot of your form to [email protected]? Our support team will estimate the task.

Displaying 1 to 3 of 3 messages

Related threads