Passing values from text field to a javascript function in Drupal 8
You do not need to use Drupal Behaviours for this, this can be done with States API which ultimately uses javascript.

e.g.

$form['calculate'] = array(
  '#type' =&gt; 'submit',
  '#states' =&gt; array(
    // Only show this field when the 'toggle_me' checkbox is enabled.
    'visible' =&gt; array(
      ':input[name="weight"]' =&gt; array(
        'filled' =&gt; TRUE,
      ':input[name="number"]' =&gt; array(
        'filled' =&gt; TRUE,
      ),
    ),
  ),
);


You can change the fields name as per your requirement. Hope this will help.

Thanks