Thing I want to do

I want to issue an alert with javascript if nothing is entered in the input form created in HTML

code in index.html
<! DOCTYPE html>
  <meta charset = "UTF-8">
  <form name = "form1" action = "cgi-bin/example.cgi" method = "post">
      <p>Enter the keyword I want to search.</p>
      <input type = "search" name = "search" placeholder = "Enter keyword">
      <input type = "submit" name = "submit" value = "search">
  <script type = "text/javascript">
        function check () {
            if (document.form1.search.value == "") {
                alert ("Please enter something");
                return false;
            else {
                return true;

What I tried

In order to check if js itself works, I tried to describe it appropriately as follows, but it worked here.

        alert ("No")

I'm a beginner of html/js, so I think there are many things I don't understand, but please give me some advice.

Reference article