Skip to main content

Validate HTML with this JavaScript Ajax function. Run it from your developer/debug console.

var validateLocalMarkup = function () {
    (function () {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', window.location, true);
        xhr.send(null);

        xhr.onreadystatechange = function () {
            if (xhr.readyState !== 4) {
                return;
            }

            if (!xhr.status || xhr.status === 200) {
                var source = xhr.responseText;
                var f = document.createElement('form'),
                    i = document.createElement('input');

                f.action = 'http://validator.w3.org/check';
                f.enctype = 'multipart/form-data';
                f.method = 'post';
                f.target = '_blank';

                i.type = 'hidden';
                i.name = 'fragment';
                i.value = source;

                f.appendChild(i);
                document.body.appendChild(f);

                f.submit();
                document.body.removeChild(f);
            }
        };
    })();
};