<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<input type="text" name="username" id="name">
<input type="text" name="password" id="password">
<input type="submit" value="提交">
</form>
<script>
function checkForm(){
var name=document.getElementById("name").value;
if(name==""||name==null){
return false;
}
var pwd=document.getElementById("password").value;
if(pwd==""||pwd==null){
return false;
}
return true;
}
</script>
</body>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" name="username" id="name">
<input type="text" name="password" id="password">
<input type="submit" value="提交">
</form>
<script>
function checkForm(){
var name=document.getElementById("name").value;
if(name==""||name==null){
return false;
}
var pwd=document.getElementById("password").value;
if(pwd==""||pwd==null){
return false;
}
return true;
}
</script>
</body>
</html>
转载:http://blog.csdn.net/s_liuxin_s/article/details/51011821