现在的位置: 首页 > 综合 > 正文

只允许输入字母或数字的文本框

2013年03月29日 ⁄ 综合 ⁄ 共 350字 ⁄ 字号 评论关闭

<html>

<head>
</head>

<body>
<input tpye="text" value="只允许输入字母" style="color:gray" onfocus="this.value='';this.style.color='black'"
onkeyup="this.value=this.value.replace(/[^a-z]/gi,'')">
<br>
<input tpye="text" value="只允许输入数字" style="color:gray" onfocus="this.value='';this.style.color='black'"
onKeyUp="this.value=this.value.replace(//D/gi,'');">
<br>
</body>
</html>

抱歉!评论已关闭.