=================================================================
<!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">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>无标题文档</title>
<script>
function check(){
if(!document.getElementById("aaa").checked){alert("你必须同意协议")return false}
return true
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<div style="border:1px solid #acewidth:800pxheight:400pxmargin:5px autopadding:5px">用户协议</div>
<div style="width:800pxmargin:5px autotext-align:right">
<p>
<label>
<input type="checkbox" name="aaa" id="aaa" />
我同意</label>
</p>
<p>
<input type="submit" name="button" id="button" value="注册" onclick="return check()" />
</p>
</div>
</form>
</body>
</html>
js禁止文本框输入用'disabled'限制。//HTML代码
<input type="text" id="text001" value="123"/>
//jQuery代码
$(function(){
$('#text001').attr('disabled',true)
})
要禁止输入其实可以不用js都可以做到
input有个属性readonly是用来设置文本框为只读的
只需要添加readonly='readonly'
就可以不让文本框输入文字了
例如<input type='text' readonly='readonly'/>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)