Показать сообщение отдельно
  #10 (permalink)  
Старый 11.04.2013, 13:24
Аспирант
Отправить личное сообщение для Hol1killer Посмотреть профиль Найти все сообщения от Hol1killer
 
Регистрация: 17.07.2012
Сообщений: 34

Так же не хочет работать

Весь код привожу что у меня есть

function SubmitValidatorFuncs() {}
SubmitValidatorFuncs.prototype = {
    submiterName: "",
    submiterDisabledClassName: "submiterDisabled",
    subValidator: Object(),
    SetSubmiterDisabeldClassName: function (a) {
        this.submiterDisabledClassName = a;
    },
    AddElem: function (a, b) {
        a = "#" + a;
        this.BindElem(a, b);
    },
    AddElemClass: function (a, b) {
        this.BindElem(a, b);
    },
    BindElem: function (a, c) {
        var b = this;
        if ((c == "input") || (c == "textarea")) {
            $(a).bind("click focus keyup paste blur", function () {
                b.subValidator.DoValidate();
            });
        } else {
            if ((c == "checkbox") || (c == "radio") || (c == "button")) {
                $(a).bind("click", function () {
                    b.subValidator.DoValidate();
                });
            } else {
                if (c == "select") {
                    $(a).bind("change", function () {
                        b.subValidator.DoValidate();
                    });
                }
            }
        }
    },
    IsChecked: function (a) {
        a = "#" + a;
        return ($(a).attr("checked") == true);
    },
    IsNotChecked: function (a) {
        return !this.IsChecked(a);
    },
    IsEmptyInput: function (a) {
        a = "#" + a;
        return ($(a).attr("value") == "");
    },
    IsNotEmptyInput: function (a) {
        return !this.IsEmptyInput(a);
    },
    IsEmptyTextarea: function (a) {
        a = "#" + a;
        return ($(a).val() == "");
    },
    IsNotEmptyTextarea: function (a) {
        return !this.IsEmptyTextarea(a);
    },
    IsSelectedZero: function (a) {
        a = "#" + a;
        return ($(a).val() == 0);
    },
    IsNotSelectedZero: function (a) {
        return !this.IsSelectedZero(a);
    },
    IsPositive: function (a) {
        a = "#" + a;
        return ($(a).val() > 0);
    },
    IsSelectedNatural: function (a) {
        a = "#" + a;
        return ($(a).val() >= 0);
    },
    IsDateValid: function (c, b) {
        c = "#" + c;
        var a = $(c).attr("value");
        if (b == "dd.mm.yyyy") {
            var f = new RegExp("^[0-3]{1}[0-9]{1}.[0-1]{1}[0-9]{1}.[0-9]{4}$");
            var d = a.match(f);
            if (d != null) {
                return true;
            } else {
                return false;
            }
        } else {
            if (b == "hh:mm") {
                var g = new RegExp("^[0-2]{1}[0-9]{1}:[0-6]{1}[0-9]{1}$");
                var d = a.match(g);
                if (d != null) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
    },
    IsEmailValid: function (c) {
        c = "#" + c;
        var b = $(c).attr("value");
        var a = new RegExp("^[^@]+@[^@.]+[.]{1}[^@.]{2,}$");
        var d = b.match(a);
        if (d == null) {
            return false;
        } else {
            return true;
        }
    },
    SetSubmiterName: function (a) {
        this.submiterName = a;
    },
    SetSubValidator: function (a) {
        this.subValidator = a;
    },
    DoChangeSubmitActive: function (b) {
        var a = "#" + this.submiterName;
        if (b) {
            $(a).removeClass(this.submiterDisabledClassName);
            $(a).removeAttr("disabled");
        } else {
            $(a).addClass(this.submiterDisabledClassName);
            $(a).attr("disabled", "disabled");
        }
    },
    DoChangeErrorClass: function (b, a) {
        var c = "#" + b + "Title";
        if (a) {
            $(c).removeClass("error");
        } else {
            $(c).addClass("error");
        }
    }
};

function SubmitValidator() {
    var a = new SubmitValidatorFuncs();
    return {
        SetSubmiterName: function (b) {
            a.SetSubmiterName(b);
        },
        SetSubValidator: function (b) {
            a.SetSubValidator(b);
        },
        AddElem: function (b, c) {
            a.AddElem(b, c);
        },
        AddElemClass: function (b, c) {
            a.AddElemClass(b, c);
        },
        IsChecked: function (b) {
            return a.IsChecked(b);
        },
        IsNotChecked: function (b) {
            return a.IsNotChecked(b);
        },
        IsEmptyInput: function (b) {
            return a.IsEmptyInput(b);
        },
        IsNotEmptyInput: function (b) {
            return a.IsNotEmptyInput(b);
        },
        IsEmptyInputTextarea: function (b) {
            return a.IsEmptyInputTextarea(b);
        },
        IsNotEmptyTextarea: function (b) {
            return a.IsNotEmptyTextarea(b);
        },
        IsSelectedZero: function (b) {
            return a.IsSelectedZero(b);
        },
        IsNotSelectedZero: function (b) {
            return a.IsNotSelectedZero(b);
        },
        IsSelectedNatural: function (b) {
            return a.IsSelectedNatural(b);
        },
        IsPositive: function (b) {
            return a.IsPositive(b);
        },
        IsDateValid: function (c, b) {
            return a.IsDateValid(c, b);
        },
        DoChangeSubmitActive: function (b) {
            a.DoChangeSubmitActive(b);
        },
        IsEmailValid: function (b) {
            return a.IsEmailValid(b);
        },
        SetSubmiterDisabeldClassName: function (b) {
            a.submiterDisabledClassName = b;
        },
        DoChangeErrorClass: function (c, b) {
            a.DoChangeErrorClass(c, b);
        }
    };
}

function OrderFormValidator() {
    this.Run();
}
OrderFormValidator.prototype = {
    validator: SubmitValidator(),
    Run: function () {
        this.validator = new SubmitValidator();
        this.validator.SetSubValidator(this);
        this.DoAddElems();
        this.DoPrepareHiddenElems();
        this.DoValidate();
    },
    AddElem: function (a, b) {
        this.validator.AddElem(a, b);
    },
    DoAddElems: function () {
        this.validator.SetSubmiterName("orderFormSubmiter");
        this.validator.AddElem("name", "input");
        this.validator.AddElem("phone", "input");
    },
    DoPrepareHiddenElems: function () {
        var a = (window.location.hash.toString() == "#order");
        if (a) {
            $("#name").focus();
        }
    },
    DoValidate: function () {
        var c = this.validator.IsNotEmptyInput("name");
        var a = this.validator.IsNotEmptyInput("phone");
        this.validator.DoChangeErrorClass("name", c);
        this.validator.DoChangeErrorClass("phone", a);
        var b = (c && a);
        this.validator.DoChangeSubmitActive(b);
    }
};
$(document).ready(function () {
    if ($("#orderFormSubmiter").length) {
        new OrderFormValidator();
    }
});
Ответить с цитированием