﻿var franchise = new Class({
    _formID: 'formFranchise',
    _testRegex: '^.+$',
    initialize: function () {
        $(this._formID).getElements("input[type=submit]").each(function (sendButton) {            
            sendButton.addEvent("click", function (e) {
                if (!this._checkForm())
                    e.stop();
            } .bind(this));
        }, this);
    },
    _checkForm: function () {
        var pass = true;
        $(this._formID).getElements("input.required").each(function (input) {
            var val = input.get("value");
            if (val && val.test(this._testRegex)) {
                input.removeClass("inputError");
            } else {
                input.addClass("inputError");
                pass = false;
            }
        }, this);
        return pass;
    }
});
