如何在HTML中利用javascript验证

来源:百度知道 编辑:UC知道 时间:2024/06/16 19:01:04
例如验证名字不能为空啊!如此等等。。。
最好还能够帮我做一个注册和登录的例子...
谢谢各位高手啦!!

<!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=gb2312" />
<title>Javascript进行表单验证</title>
<script type="text/javascript">
function jc(){
var a = document.form1.UserName.value;
if (a ==""){
alert("你输入的用户名不能为空!");
return false;
}
var b = document.form1.UserPwd.value;
if (b.length<6){
alert("你输入的密码小于6!");
return false;
}
return true;
}
</script&g