Adding more code to custom javascript

I added a plugin so have customer java under form settings. Add one code, thanks to help from here. The code ends });.

I’ve to add more code to provide another function and it doesn’t work, nor does the original code. Please can I have help on how to finish one code, then start another so both work?

Thanks

Can you post the code here that you are trying to use or combine? Be sure to use three backticks on a new line before the code you post, and after, so it is properly formatted as code. This is what code will look like when properly posted (this happens to be PHP):

<?php
// If the add-on framework isn't there, bail.
if( ! is_callable( array( 'GFForms', 'include_addon_framework' ) ) ) {
	return;
}

// Include the addon framework.
GFForms::include_addon_framework();


/**
 * Class GFDebug
 */
class GFDebug extends GFAddOn {

	/**
	 * @var string
	 */
    protected $_version = '1.0.beta8';
}

The backticks look like this when you post:

The backtick is normally on the key above the TAB key.

ETTnT

Thanks Chris.

Below is the original code which works:

gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
	// Apply to field 1 only 
    if ( fieldId == 1 ) {
 
 optionsObj.minDate = 0;
 optionsObj.maxDate = '+1 M';
 
 }
 return optionsObj;
 });

I want to now add another code under form settings java script to exclude certain years in another field ID.

Regards
Steve

OK, you should just be able to add them after the existing code. What issue are you running into?

The original and the additional codes don’t work. Will try the backticks. Can’t see it on my keyboard, but will copy and paste it in.

Thanks

This is the second code I wish to add:

gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
    if ( formId == 1 && fieldId == 11, 17 ) {
 
        // Years to disable 
        monthsDisabled = [2019, 2018, 2017, 2016];
 
        optionsObj.beforeShowDay = function(date) {
            if (jQuery.inArray(date.getYear(), YearsDisabled) > -1) {
                return [false, ''];
            }
            return [true, ''];
        };
    }
    return optionsObj;
});

That is not the correct syntax. If you want the code to apply to field 11 or field 17 in form 1, this would be correct:

if ( ( formId == 1 && fieldId == 11 ) || ( formId == 1 && fieldId  17 ) ) {

That say “If form ID 1 and field ID 11 OR form ID 1 and field ID 17” then apply the code.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.