validform.js+layer.js 表單驗證樣式

$("#formAdd").Validform({
                tiptype: function (msg, o, cssctl) {
                    if (o.type == 3) {//失敗
                        layer.tips(msg, o.obj, {
                            tips: [1, '#F74D4D'],
                            time: 3000
                        });
                        $(window).scrollTop(o.obj.offset().top - 40);
                    }
                },
                datatype: {//自定義驗證類型
                    "select": function (gets, obj, curform, regxp) {
                        if (gets == "") {
                            return false;
                        } else {
                            return true;
                        }
                    }
                },
                ignoreHidden: true,
                tipSweep: true, //若爲true,則只在表單提交時驗證
                ajaxPost: true, //異步提交
                beforeCheck: function (curform) {
                },
                beforeSubmit: function (curform) {
                    
                },
                callback: function (data) {//異步回調函數
                    if (data) {
                        var index = layer.alert(data.Message, function () {
                            if (data.Success) {
                                location.href = "Index";
                            } else {
                                layer.close(index);
                            }
                        });

                    }
                }
            });
相關文章
相關標籤/搜索