Created
February 8, 2012 17:21
-
-
Save mygoare/1771401 to your computer and use it in GitHub Desktop.
回学校自己手写的一些代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
回校第一天晚上: | |
表单验证 | |
<!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" xml:lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | |
<title>form</title> | |
</head> | |
<body> | |
<form action="welcome.php" method="post" name="testForm" > | |
Name: | |
<input type="text" name="name" id="name" /> | |
Age: | |
<input type="text" name="age" id="age"/> | |
<input type="submit" value="submit" onclick="return checkForm()" /> | |
<script type="text/javascript"> | |
function checkForm() | |
{ | |
//var name = document.getElementById("name").value; | |
//var age = document.getElementById("age").value; | |
var name = document.testName.name.value; | |
var age = document.testName.age.value; | |
if(!(name && age)) | |
{ | |
alert("something wrong!"); | |
document.testForm.age.focus(); | |
return false; | |
} | |
} | |
</script> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment