html5表单失去焦点进行非空验证,并用placeholder显示错误提示
<!DOCTYPEhtml><html><head><metacharset="UTF-8"/><title>checkValidity示例</title></head>...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>checkValidity 示例</title>
</head>
<body>
<form action="" method="get">
<table width="200%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="uname" type="text" placeholder="ID"></td>
</tr>
<tr>
<td><input name="pwd" type="password" placeholder="密码"></td>
</tr>
<tr>
<td><input name="" type="submit"></td>
</tr>
</table>
</form>
</body>
</html>
表单失去焦点验证是否为空,为空就用placeholder红色字体显示提示信息
急!!!在线等 展开
<html>
<head>
<meta charset="UTF-8"/>
<title>checkValidity 示例</title>
</head>
<body>
<form action="" method="get">
<table width="200%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="uname" type="text" placeholder="ID"></td>
</tr>
<tr>
<td><input name="pwd" type="password" placeholder="密码"></td>
</tr>
<tr>
<td><input name="" type="submit"></td>
</tr>
</table>
</form>
</body>
</html>
表单失去焦点验证是否为空,为空就用placeholder红色字体显示提示信息
急!!!在线等 展开
展开全部
简单改了下你的,效果实现了,规范的写法自己改改吧
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>checkValidity 示例</title>
<style>
input.dd::-webkit-input-placeholder{
color: red;
opacity:1;
}
</style>
</head>
<body>
<form action="" method="get">
<table width="200%" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td><input class='' id='id' name="uname" type="text" placeholder="ID" onblur="aa(this)"></td>
</tr>
<tr>
<td><input name="pwd" type="password" placeholder="密码"></td>
</tr>
<tr>
<td><input name="" type="submit"></td>
</tr>
</table>
</form>
<script>
function aa(a){
if(a.value==''){
a.placeholder='ID不能为空';
a.className="dd";
}
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询