{"id":694,"date":"2017-08-31T22:02:23","date_gmt":"2017-08-31T14:02:23","guid":{"rendered":"http:\/\/loveuhouse.cn\/wordpress\/?p=694"},"modified":"2017-09-04T18:09:38","modified_gmt":"2017-09-04T10:09:38","slug":"bootstrap-validator-v0-5-1-dev-%e7%88%86%e7%82%b8%e5%9d%91","status":"publish","type":"post","link":"https:\/\/loveuhouse.cn\/wordpress\/?p=694","title":{"rendered":"bootstrap Validator v0.5.1-dev \u7206\u70b8\u5751"},"content":{"rendered":"<p>\u53c2\u8003<br \/>\n<a href=\"http:\/\/1000hz.github.io\/bootstrap-validator\/#\">http:\/\/1000hz.github.io\/bootstrap-validator\/#<\/a><br \/>\n<a href=\"http:\/\/formvalidation.io\/download\/\">http:\/\/formvalidation.io\/download\/<\/a><br \/>\n<a href=\"http:\/\/blog.csdn.net\/u013938465\/article\/details\/53507109\">http:\/\/blog.csdn.net\/u013938465\/article\/details\/53507109<\/a><\/p>\n<h2>\u795e\u5947\u7684\u53d8\u91cf\u547d\u540d<\/h2>\n<p>a:<br \/>\nb: \u9700\u9a8c\u8bc1\u5b57\u6bb5<br \/>\nc: message\u5bb9\u5668\/\u914d\u7f6e<br \/>\nd: \u8868\u5355\u5143\u7d20\u7684type<\/p>\n<h2>\u9ed8\u8ba4\u5b57\u6bb5<\/h2>\n<p>\u83b7\u53d6\u65b9\u5f0f <code>$.fn.bootstrapValidator.DEFAULT_OPTIONS<\/code><\/p>\n<pre><code>{\n    \"elementClass\": \"bv-form\",\n    \"message\": \"This value is not valid\",\n    \"group\": \".form-group\",\n    \"container\": null,\n    \"threshold\": null,\n    \"excluded\": [\n        \":disabled\",\n        \":hidden\",\n        \":not(:visible)\"\n    ],\n    \"feedbackIcons\": {\n        \"valid\": null,\n        \"invalid\": null,\n        \"validating\": null\n    },\n    \"submitButtons\": \"[type=\\\"submit\\\"]\",\n    \"live\": \"enabled\",\n    \"fields\": null\n}\nfields={\n    container \n    excluded\n    feedbackIcons\n    group\n    message\n    onError\n    onStatus\n    onSuccess\n    selector\n    threshold \u5f00\u59cb\u9a8c\u8bc1\u957f\u5ea6\uff08\u5bf9radio\u7c7b\u578b\u65e0\u6548\uff09\n    trigger     \u89e6\u53d1\u9a8c\u8bc1\u7684\u52a8\u4f5c\u4f8b\u5982\uff1akeyup(\u6309\u952e)\/blur(\u5931\u53bb\u7126\u70b9)\n    validators\n}\n\nfields.validators = {\n\n    callback\uff1a{\n        message:[string],\n        callback: [function]\n    },\n\n    notEmpty\n\n    numeric: {\n        message:[string],\n        separator: [function]\n    },\n\n\n\n}\n\n<\/code><\/pre>\n<h2>\u6817\u5b50<\/h2>\n<pre><code>$(\"#agentCreate\").bootstrapValidator({\n        feedbackIcons:{\n            valid: 'glyphicon glyphicon-ok',\n            invalid: 'glyphicon glyphicon-remove',\n            validating: 'glyphicon glyphicon-refresh'\n        },\n        message:'\u4e0d\u80fd\u4e3a\u7a7a',\n        fields:{\n            title:{\n                validators: {\n                    notEmpty: {}\n                }\n            },\n            file:{\n                validators: {\n                    notEmpty: {}\n                }\n            },\n        }\n    }).on('success.form.bv', function(e) {\n                \/\/ \u963b\u6b62\u9ed8\u8ba4\u4e8b\u4ef6\u63d0\u4ea4\n                e.preventDefault();\n            });\n    $(\"#sub\").on(\"click\", function () {\n        \/\/\u83b7\u53d6\u8868\u5355\u5bf9\u8c61\n        var bootstrapValidator = $(\"#agentCreate\").data('bootstrapValidator');\n        \/\/\u624b\u52a8\u89e6\u53d1\u9a8c\u8bc1\n        bootstrapValidator.validate();\n        if (bootstrapValidator.isValid()) {\n            console.log(\"bootstrapValidator\", arguments);\n            \/\/\u8868\u5355\u63d0\u4ea4\u7684\u65b9\u6cd5\u3001\u6bd4\u5982ajax\u63d0\u4ea4\n\n        }\n    })\n<\/code><\/pre>\n<h2>\u64cd\u4f5c<\/h2>\n<h3>\u83b7\u53d6\u5df2\u914d\u7f6e\u7684\u8868\u5355\u5143\u7d20<\/h3>\n<pre><code>$(\"#agentCreate\").data(\"bootstrapValidator\").getInvalidFields()\n<\/code><\/pre>\n<h3>\u83b7\u53d6\u914d\u7f6e<\/h3>\n<pre><code>$(\"#agentCreate\").data(\"bootstrapValidator\").getOptions()\n<\/code><\/pre>\n<h3>\u91cd\u7f6e\u67d0\u5b57\u6bb5(\u4f1a\u6e05\u7a7a\u5bf9\u5e94\u8868\u5355\u5143\u7d20\u6570\u636e)<\/h3>\n<pre><code>$(\"#agentCreate\").data(\"bootstrapValidator\").resetField(\"imgId\",\"#imgSelector\")\n\n<\/code><\/pre>\n<h3>\u66f4\u65b0\u67d0\u5b57\u6bb5\u72b6\u6001\uff08\u4e0d\u4f1a\u6e05\u7a7a\u6570\u636e\uff09<\/h3>\n<pre><code>$(formName).data(\u201cbootstrapValidator\u201d).updateStatus(\"fieldName\",  \"NOT_VALIDATED\",  null );\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003 http:\/\/1000hz.github.io\/bootstrap-validator\/# http:\/ &hellip; <a href=\"https:\/\/loveuhouse.cn\/wordpress\/?p=694\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">bootstrap Validator v0.5.1-dev \u7206\u70b8\u5751<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/694"}],"collection":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=694"}],"version-history":[{"count":7,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/694\/revisions"}],"predecessor-version":[{"id":701,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/694\/revisions\/701"}],"wp:attachment":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}