Floating Number-Field in a Form

Hello everyone,

I’m quite new to Drupal and developing a little Wizard for my company. But i do not get the number field to accept any floatingpoint values or the text field to validate, that my text is really a number.

I do know the question did not arrise the first time, but nothing i found could solve my problem.

First approach:

        $form[self::WARMMIETE] = array(
          ‘#type’ => ‘number’,
            ‘#min’ => 0,
            ‘#required’ => TRUE,
            ‘#suffix’ => ‘€’,

Second approach:

        $form[self::WARMMIETE] = array(
          ‘#type’ => ‘textfield’,
            ‘#required’ => TRUE,
            ‘#validate’ => ‘moneyValidation’,
            ‘#suffix’ => ‘€’,

    function moneyValidation($element, &$form_state, $form){
      if (!is_float( $element[‘#value’]))
        form_error($element, t(‘Der eingegebene Wert darf nur Zahlen enthalten.’));

      if(($element[‘#value’]) < 0)
        form_error($element, t(‘Eine Warmmiete muss größer als 0€ sein.’));

I’m working with drupal 8.5. I hope sombody can help me.

Best Regards

Drupal version: 

Source: https://www.drupal.org/taxonomy/term/4/feed