zoukankan      html  css  js  c++  java
  • js判断登陆用户名及密码是否为空的简单实例

    js判断登陆用户名及密码是否为空的简单实例

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <script type="text/javascript">
    // 验证输入不为空的脚本代码
    function checkForm(form) {
    if(form.username.value == "") {
    alert("用户名不能为空!");
    form.username.focus();
    return false;
    }
    if(form.password.value == "") {
    alert("密码不能为空!");
    form.password.focus();
    return false;
    }
    return true;
    }
    </script>

    PS一下 调用的话 如果是表单调用  即是 

    1
    <form action="#" method="post" onsubmit="return checkForm(this);">

    以上这篇js判断登陆用户名及密码是否为空的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

  • 相关阅读:
    alpha冲刺9
    alpha冲刺8
    alpha冲刺7
    alpha冲6
    随堂小测-同学录
    alpha冲刺5
    任务3
    任务2
    任务1
    网站用户行为分析
  • 原文地址:https://www.cnblogs.com/to-creat/p/7163109.html
Copyright © 2011-2022 走看看