简单改了下你的,效果实现了,规范的写法自己改改吧
<!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>
<html><head>
<meta http-equiv="Content-Type" content="text/html charset=gb2312" />
<title>文哥讨厌IE</title>
<script language="javascript" type="text/javascript">
function checkMobile(str) {
if(str==""){
alert("手机号不能为空!")
}
else{
var re = /^1\d{10}$/
if (re.test(str)) {
alert("正确")
} else {
alert("手机号格式错误!")
}
}
}
</script>
</head>
<body>
<input type="text" id="btn_getNum"/>
<input type="button" value="得到数字" onclick="checkMobile(btn_getNum.value)"/>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)