今天自学了java做出了第一个小程序
实现了表单控件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>form事件控件</title>
<style>
#login{
border-radius: 30px;
width: 200px;
border: 1px solid black;
margin: 100px 500px;
padding: 10px 20px;
}
#submit,#loginname{
text-align: center;
font-size: 15px;
color: cyan;
padding: 5px 0 5px 0;
}
#submitbutton{
background-color: cyan;
border: 0px;
border-radius: 20px;
padding: 0px 50px;
}
</style>
</head>
<body>
<form id="login">
<div id="loginname">
登录信息
</div>
<div style="width: 150px;color:red; visibility: hidden;" id="point">
提示信息
</div>
<div>
<input type="text" placeholder="请输入文字" οnblur="Focus(this)" οnfοcus="Blur(this)"/>
</div>
<div style=" width: 150px;color: red;visibility: hidden" id="point1">
提示信息
</div>
<div>
<input type="text" placeholder="请输入" οnblur="Focus1(this)" οnfοcus="Blur1(this)">
</div>
<div id="submit">
<input type="submit" id="submitbutton" value="登录">
</div>
</form>
</body>
<script>
function Focus(elem) {
var elemValue=elem.value;
var borderColor = elem.style.borderColor;
var point= document.getElementById("point");
if (elemValue==""){
point.innerHTML="请输入用户名";
elem.style.borderColor="red";
point.style.visibility="visible";
}else if(borderColor=="red"){
elem.style.borderColor="";
point.style.visibility="hidden";
}
}
function Blur(elem) {
var borderColor=elem.style.borderColor;
var point=document.getElementById("point");
if (borderColor=="red"){
elem.style.borderColor="";
point.style.visibility="hidden";
}
}
function Focus1(elem) {
var elemValue=elem.value;
var borderColor = elem.style.borderColor;
var point1= document.getElementById("point1");
if (elemValue==""){
point1.innerHTML="请输入密码";
elem.style.borderColor="red";
point1.style.visibility="visible";
}else if(borderColor=="red"){
elem.style.borderColor="";
point1.style.visibility="hidden";
}
}
function Blur1(elem) {
var borderColor=elem.style.borderColor;
var point1=document.getElementById("point1");
if (borderColor=="red"){
elem.style.borderColor="";
point1.style.visibility="hidden";
}
}
</script>
</html>