62,074
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
function check(){
var num=document.getElementById("txtNum");
var tishi=document.getElementById("txttishi");
if(isNaN(num.value)){
tishi.value="只能为正整数!";
return false;
}
if(num.value.length<3 || num.value.length>8){
tishi.value="长度应在3-8位之间";
return false;
}else{
tishi.value="";
return true;
}
}
</script>
<input type="text" id="txtNum" onkeypress="check()" />
<input type="text" id="txttishi" />
function check(){
var num=document.getElementById("txtNum");
if(isNaN(num)){
alert("只能为正整数!");
return false;
}
if(num.length<3 || num.length>8){
alert("长度应在3-12位之间");
return false;
}else{
return true;
}
}
你可以试下!希望帮到你!<input runat="server" type="text" id="linkorder" name="linkorder" onkeyup="value=value.replace(/[^0-9_]/g,'')" />