Q: Regular expression to validate FQDN I am trying to use following Regular Expression to validate FQDN in Javascript. This works fine in C#. But Page throws 403 error when used in javascript. What am i doing wrong?
 if (!fqdn.match(/(?=^.{1,254}$)(^(?:(?!\d|-)[a-zA-Z0-9\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)/)) 
    {
        alert("Not a valid FQDN");               
        return false;           
    }


A: Your regex uses a negative lookbehind assertion (?<!-), and those aren't supported by JavaScript.
You can rewrite your regex to match exactly the same way without lookbehinds:
/(?=^.{1,254}$)(^(?:(?!\d|-)[a-z0-9-]{0,62}[a-z0-9]\.?)+(?:[a-z]{2,})$)/i

I'm not so sure if the logic behind the regex really is correct for validating a FQDN, though, but that's a different problem. For example, the optional dot makes the regex susceptible to catastrophic backtracking. This is a good way to crash your browser.
