当前位置: 代码迷 >> JavaScript >> Javascript惯用方法积累
  详细解决方案

Javascript惯用方法积累

热度:247   发布时间:2012-10-26 10:30:58.0
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);
}
  相关解决方案