function is_number(field,div_id)
//div_id是显示错误的div的ID
{
var patt=new RegExp("^[0-9]{1,2}$");//建立正则表达式对象patt
with(field){
if(patt.test(value)==false){//调用patt的test方法
document.getElementById(div_id).style.display="block";
return false;
}else{
document.getElementById(div_id).style.display="none";
return true;
}
}
原文地址:http://www.cnblogs.com/beast-king/p/3852612.html