window.onload = function () {
    var formEl = document.getElementById("myForm")
      , checkboxEl = document.getElementsByName("xhr")[0]
      , nameEl = document.getElementsByTagName("name")[0]
      ;

    formEl.addEventListener("submit", function () {
        if (!checkboxEl.checked) { return; }
    });
};

window.onload = function () {
    var formEl = document.getElementById("myForm")
      , checkboxEl = document.getElementsByName("xhr")[0]
      , nameEl = document.getElementsByTagName("name")[0]
      , formToSubmit = new XHRFormSubmitter({form: formEl})
      ;

    formEl.addEventListener("submit", function (e) {
        if (!checkboxEl.checked) { return; }
        formToSubmit.submit();
        e.preventDefault();
    });
};

Create a new XHRFormSubmitter and use submit method
Create a new XHRFormSubmitter and use submit method
