/* $Id: is_dotted_quad.js,v 1.1 2003/06/11 20:09:15 nstephen Exp $
 *
 * Author:  Graham Cebulskie
 *
 * Compatibility:  JavaScript 1.2+
 *
 * is_dotted_quad(x)
 *
 * returns true if x is an IPV4 IP number in dotted quad format
 * returns false otherwise
 *
 */

var GLOBAL_CLOUD_IS_DOTTED_QUAD_RE = /^([0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3})/;
GLOBAL_CLOUD_IS_DOTTED_QUAD_RE.compile();

function is_dotted_quad(x) {
  if(GLOBAL_CLOUD_IS_DOTTED_QUAD_RE.exec(x)) {
    if(Math.abs(RegExp.$1) > 255) return false;
    if(Math.abs(RegExp.$2) > 255) return false;
    if(Math.abs(RegExp.$3) > 255) return false;
    if(Math.abs(RegExp.$4) > 255) return false;
    return true;
  }
  return re.test(x);
}

