js提示无对象,我应该如何改啊?
<form action="" method="post" enctype="multipart/form-data" name="form1">
测试
<input onBlur="chg(2)" name="textarea" type="text" value="">
</form>
<script type="text/javascript" ></script>
<script language="javascript">
function isNum(s){
for(var i=0;i<s.length;i++){
var c=s.charAt(i);
if((c<'0' || c>'9') && c!='.' && c!='-' && c==''){ alert('输入不合法,请输入数字!');}
}
return true;
}
function chg(numset){
if(!checkInt(event.srcElement.value,"","")){
alert('输入不合法,请输入数字!');
event.srcElement.value='';
}
if(event.srcElement.value!=""){
event.srcElement.value=formatFloat(event.srcElement.value,numset);
}
}
</script>
------解决方案--------------------
HTML code
<form action="" method="post" enctype="multipart/form-data" name="form1">
测试
<input onBlur="chg(this)" name="textarea" type="text" value="">
</form>
<script type="text/javascript" ></script>
<script language="javascript">
var re = /^\d+$/;
function chg(t){
if( !re.test(t.value) ){
alert('输入不合法,请输入数字')
}
}
</script>