How to display a warning message
That’s the browser validation message appearing. If you want to show Drupal messages only, you need to set the no-validate attribute on the form tag itself so browsers ignore it. Drupal will still run validation on submission.