A pop-up prompt for whether the search form submission is empty

Today I shared about judging whether the search form is empty. If it is empty, it will prompt that the search keyword is empty. The code is as follows:

  

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!--搜索表单-->

<script type="text/javascript">

    function notNull() {

        if (document.keyinput.kw.value.toString().trim().length <= 0) {

              alert("您未输入关键词!");

              document.keyinput.kw.focus();

              return false;

            }else {

              return true;

          }

     }

</script>

<div class="search clearfloat" id="search">

    <form method="get" action="http://www.zjkweiqi.cn/ search.php" class="search-form" name="keyinput">

    <input type="text" name="kw" placeholder="请输入商品/产品名,就能获取您需要的产品下载信息!"/>

        <button type="submit" onclick="return notNull()">搜一下</button>

    </form>

</div>

<!--搜索表单-->

  

Guess you like

Origin blog.csdn.net/qq_41608099/article/details/108109551