首页 > 代码库 > WEB只能输入固定的字符

WEB只能输入固定的字符

<head runat="server">
<title></title>
<script type="text/javascript">
function CheckageVal(val) {
for (var i = 0; i < val.length; i++) {
if (event.keyCode == val.charCodeAt(i)) {
return true;
}
} return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc:Head ID="head" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" onkeypress="return CheckageVal(‘qwe‘)"></asp:TextBox>
</div>
</form>
</body>