Alpaca Forms (alpacajs) and adding another button that is only enabled when the form is valid

The submit button is disabled by default in Alpaca Forms until the form passes validation. You can add more buttons easily (see the documentation on forms) but having them share this behavior isn’t straightforward. The answer is to add the class ‘alpaca-form-button-submit’ to the button using the ‘styles’ property:

'form': {
        'attributes': {
            'id': 'alpaca_form'
        },
        'buttons': {
            'another_button': {
                'label': 'Clickable when valid',
                'click': function(e) {
                    do_something();
                },
                'styles': 'alpaca-form-button-submit'
                }
            }
        }
}

For a full explanation, search for the enableSubmitButton and adjustSubmitButtonState functions in the source code.