正则。IP验证
function checkIP() //检查IP { var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; obj=document.getElementById("NTPaddress").value; var reg1 = obj.match(exp); if(reg1==null){ alert("NTP地址输入不合法!"); return false; }else{ //alert("修改成功!"); setTimeSet(); return true; } }