AJS.toInit(function ($) {
    var verifiableFields = $(".verifiable");
    var url = $("#verify-action").val();

    verifiableFields.each(function() {
        var inputObj = $(".inputField", this);
        inputObj.change(function() {
            var errorObj = $(".error", this.parent);
            $.get(url, {key: inputObj.val()}, function(xmlResponse) {
                var responseObj = $(xmlResponse).find("response");
                var booleanValue = responseObj.attr("result");
                var responseText = responseObj.text();

                errorObj.remove();

                if (booleanValue == "false") {
                    inputObj.before("<div id='" + inputObj.attr("id") + "-error' class='error'><span class='errorMessage'>" + responseText + "</span></div>");
                }
            });
        });
    });
});