标签:
1、js验证radio是否选择
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="js/jquery-2.2.2.min.js">
</script>
<script type="text/javascript">
function checkform(obj) {
for (i = 0; i < obj.oo.length; i++)
if (obj.oo[i].checked == true) {
return true;
} else {
alert("请选择")
return false;
}
}
</script>
</head>
<body>
<form id="form" name="form" method="post" action="" onsubmit="return checkform(this)">
<input type="radio" name="oo" value="radiobutton"/>选项一
<input type="radio" name="oo" value="radiobutton"/>选项二
<input type="submit" name="Submit" value="提交"/>
</form>
</body>
</html>
2、长度限制
<script>
function test() {
if (document.a.b.value.length > 5) {
alert("不能超过5个字符!");
document.a.b.focus();
return false;
}
}
</script>
<form name="a" onsubmit="">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6" onchange="return test()"></textarea>
</form>
3、只能是汉字
标签:
原文地址:http://www.cnblogs.com/theWayToAce/p/5500321.html