ono
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
>
<
title
>测试页</
title
>
<
script
type
=
"text/javascript"
>
function check(){
if(form1.user.value.trim()==""){
alert("请输入用户名!");
form1.user.focus();
return;
}
else if(form1.pwd.value.trim()==""){
alert("请输入密码!");
form1.pwd.focus();
return;
}
else{
form1.submit();
}
}
</
script
>
</
head
>
<
body
>
<
form
name
=
"form1"
method
=
"post"
action
=
"Cover.html"
>
用户名:<
input
name
=
"user"
type
=
"text"
id
=
"user"
>
密码:<
input
name
=
"pwd"
type
=
"text"
id
=
"pwd"
>
<
input
name
=
"btnLogin"
type
=
"button"
value
=
"登录"
>
<
input
name
=
"btnRes"
type
=
"reset"
value
=
"重置"
>
</
form
>
</
body
>
</
html
>
|
在HEML中调用事件处理程序,在登录按钮的onclick事件中调用check()函数,实现登录验证。
本文转自stock0991 51CTO博客,原文链接:http://blog.51cto.com/qing0991/1341344,如需转载请自行联系原作者