How to get field value of form before submit? I am trying to get the value of group_name field once data entered by user before submitting the form. Then only I can access the db, where the entered data is exist in db or not using query. If exists, it shows the data of that id (selected group name id) on the below fields dynamically.
Here is my code:

   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['group_name'] = array(
       '#type' =&gt; 'textfield',
       '#title' =&gt; $this-&gt;t('Name of Group (e.g. name of school, organization, business, etc.)'),
       '#validated' =&gt; TRUE,
    );

   /******get the entered group name here********/

    $form['gi_additions_changes'] = array(
       '#type' =&gt; 'textfield',
       '#title' =&gt; $this-&gt;t('If any additions or changes need to be made to your group info above, please let us know'),
       '#validated' =&gt; TRUE,
    );

    $form['add_group_name'] = array(
       '#type' =&gt; 'textfield',
       '#title' =&gt; $this-&gt;t('Name of Group (e.g. name of school, organization, business, etc.)'),
       '#validated' =&gt; TRUE,
       //'#default_value' =&gt; ($get_form_data) ? $get_form_data-&gt;group_name : ''
    );
  return $form;
 }
If I'm not wrong, you want to update the other fields based on group_name entered by user. To achieve this you can use AJAX API provided by Drupal 8 Core.

If you don't know how to use/work with AJAX API, you can have a look at Examples for Developers module which provides working examples for many of the functionality. To see AJAX API Example, you can install "Form API Example" Sub-Module from Examples Module. Feel free to go through Examples Module code for any help you need.