if (!/^(d{1,2}|1dd|2[0-4]d|25[0-5])(.(d{1,2}|1dd|2[0-4]d|25[0-5])){3}$/.test($.trim($('#addIPAddress').val()))) { alert('IP地址格式不正确,请重新输入!'); $('#addIPAddress').focus(); }