日期:2014-05-16  浏览次数:20355 次

Javascript常用方法积累
$ = function(s) {return (typeof s == 'object') ? s: document.getElementById(s);}


/*
* 检查是否为IP
* @param value
*/
function validateIP(value) {
  var ip = '(25[0-5]|2[0-4]\\d|1\\d\\d|\\d\\d|\\d)';
  var ipdot = ip + '\\.';
  var isIPaddress = new RegExp('^'+ipdot+ipdot+ipdot+ip+'$');
  return isIPaddress.test(value);
}