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判断登陆用户名及密码是否为空的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
原文:http://www.cnblogs.com/to-creat/p/7163109.html