How to get the current field value in Ajax callback? I 've a problem with Drupal 8 ajax callbacking. I created a multivalue field for country - region listing as new field type using a custom module. In first selectlist I loaded all country codes and I set this field as multivalued.

I wrote the below code in FieldWidgetType Class.

     public function formElement(FieldItemListInterface $items, $delta, array $element, array &amp;$form, FormStateInterface $form_state) {
  $element['value'] =  array(
      '#type' =&gt; 'select',
      '#title' =&gt; 'Select Country', 
      '#name' =&gt; 'value',   
      '#options' =&gt; array(
        0 =&gt; t('- Select Country -')) + $termNameArr,
      '#default_value' =&gt; isset($items[$delta]-&gt;value) ? $items[$delta]-&gt;value : NULL,
      '#ajax' =&gt; [
              'callback' =&gt; array($this, '_regions_ajax_callback'),
              'event' =&gt; 'change',
              'progress' =&gt; array(
                 'type' =&gt; 'throbber',
                 'message' =&gt; t('Please wait.Fetching data...'),
                ),
             ],  
      '#suffix' =&gt; '&lt;span class="email-valid-message"&gt;&lt;/span&gt;'
    );
    return $element;
    }


I have to load regions of the selected country in an another select box using ajax. The selectbox should populate with the regions of selected country in change event of country select box item (here I'm calling ajax). Or else, can ajax simply return the selected country value to append in span (.email-valid-message) specified in #suffix.

My current callback to return at least the selected country name is:

    public function _regions_ajax_callback(&amp;$form, &amp;$form_state) {
      $response = new AjaxResponse();
      $element = $form['value'];
      $default_value = isset($element['#default_value']) ? element['#default_value'] : NULL;
      $value = $form_state-&gt;getValue($element['#name']);
      $changed = $default_value == $value;
        if ($changed) {
       $response-&gt;addCommand(new HtmlCommand('.email-valid-message', $value));
       }
    return $response;
    }


I used namespaces 

    use Drupal\Core\Ajax\AjaxResponse;
    use Drupal\Core\Ajax\HtmlCommand;


What am I doing wrong? How can I change my callback function to get current field value? Did I miss to add any namespace?
in your _regions_ajax_callback()

$element = $form_state-&gt;getTriggeringElement();
element['#value'] &lt;-- value is in here