• Resolved rocketpig3

    (@rocketpig3)


    Thanks @codepeople for the help with those last two queries.

    I am just wondering, is there a way to prevent the user being able to calculate an output without filling in the required fields?

    Currently, I am using two sliders, one set of checkboxes (required) and three radio selects (required). However, the user can still click the calculate button and have an output produced in the calculated field even if they only fill out one of the three required radio fields.

    I would like the form to display an error message at the bottom stating that the required fields must be filled in, and for the form to not display an output, until all required fields have bee filled in.

    How might I achieve this?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @rocketpig3

    There are different alternatives.

    You can include a conditional operation as part of the equation. For example, assuming the equation is: fieldname1+fieldname2 and you want to return the result only if the user has populated the fields values. You can edit the equation as follows:

    IF(AND(fieldname1,fieldname2), fieldname1+fieldname2, '')

    Or you can validate the form from the calculate button, to prevent the evaluation of the equations if the values of form fields are invalid. Enter the following piece of code as the onclick event of calculate button:

    
    if(jQuery(this.form).valid()){jQuery(this).addClass('calculate-button');}else{jQuery(this).removeClass('calculate-button');}
    

    and that’s all.
    Best regards.

    Thread Starter rocketpig3

    (@rocketpig3)

    Thanks @codepeople.

    So if I wanted to use option one, but include an error message like “Please fill out all required fields”, I would have to have this as an HTML field and then show it based on the IF statement, is that correct? Or is there a better way of doing it?

    Thanks.

    Plugin Author codepeople

    (@codepeople)

    Hello @rocketpig3

    You are free to implement the behavior you want, for example, you can insert a “HTML Content” field or an “Instruct. Text” field with the message, and then, in the settings of calculated field, define a dependency like: If value is equal to 0, and
    select the field with the message from the list of dependent fields (https://cff.dwbooster.com/documentation#dependencies)

    Best regards.

    Thread Starter rocketpig3

    (@rocketpig3)

    OK @codepeople that makes sense.

    Is it possible to make radio select fields display a red “This field is required” notice when not filled in?

    On my form, this message will appear when I have not selected one of the checkboxes in the checkbox field, but leaving the radio selects blank will not force the form to print a message, even though they are required and have the asterisk.

    I have tried unchecking “Allow untick choices” but this has not worked.

    Thanks.

    Plugin Author codepeople

    (@codepeople)

    Hello @rocketpig3

    Q: Is it possible to make radio select fields display a red “This field is required” notice when not filled in?

    A: The message is displayed when the form is being submitted or the field loses the focus without ticking any choice.

    By the way, if you want all validation rules be evaluated immediately after the form loaded to display all error messages.

    – Insert a “HTML Content” field in the form, with the following piece of code as its content:

    
    <script>
    fbuilderjQuery(document).one('showHideDepEvet', function(){
    fbuilderjQuery('[id*="cp_calculatedfieldsf_pform_"]').valid();
    });
    </script>
    

    and that’s all.
    Best regards.

    Thread Starter rocketpig3

    (@rocketpig3)

    A: The message is displayed when the form is being submitted or the field loses the focus without ticking any choice.

    This does not occur for my radio select fields unfortunately, even with that HTML field script in use.

    Do you mind if I email you the URL?

    Plugin Author codepeople

    (@codepeople)

    Hello @rocketpig3

    If you prefer, you can contact me through my private website: Contact Us

    Best regards.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Disallowing calculation when fields not filled in’ is closed to new replies.