weber on July 22nd, 2009

Three JavaScript prototype functions for IP address, URI and Domain name validation. String.prototype.isDomain = function() { // supports all ccTLDs, gTLDs, IDNs var dom_pattern = /^(xn--)?[a-z\d]+([\.\-_][a-z\d]+)*\.([a-z]{2,4}|museum|travel|xn--[a-z\d]+)$/i;   return dom_pattern.test(this); }

Continue reading about IP/URI/Domain validation

weber on April 24th, 2009

Here is the example of JavaScript function which returns full path to the element in DOM tree (requires JQuery): DOMPath = function(me) { myId = function(me) { return me.id ? ‘#’ + me.id : ” } myTag = function(me) { return me.tagName ? me.tagName.toLowerCase() : ” } myClass = function(me) { return me.className ? ‘.’ [...]

Continue reading about Full path to the element in DOM tree