{"id":19969440,"url":"https://github.com/maelweb/mvalidate","last_synced_at":"2026-05-09T22:01:48.391Z","repository":{"id":82822737,"uuid":"49932413","full_name":"MaelWeb/Mvalidate","owner":"MaelWeb","description":null,"archived":false,"fork":false,"pushed_at":"2016-01-19T10:32:56.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T09:09:04.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaelWeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-19T06:43:00.000Z","updated_at":"2016-01-19T09:31:12.000Z","dependencies_parsed_at":"2023-03-20T02:30:41.112Z","dependency_job_id":null,"html_url":"https://github.com/MaelWeb/Mvalidate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaelWeb%2FMvalidate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaelWeb%2FMvalidate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaelWeb%2FMvalidate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaelWeb%2FMvalidate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaelWeb","download_url":"https://codeload.github.com/MaelWeb/Mvalidate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241404222,"owners_count":19957650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T02:50:05.753Z","updated_at":"2026-05-09T22:01:43.368Z","avatar_url":"https://github.com/MaelWeb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mvalidate\n\n表单格式验证, 依赖jQuery。\n\n#How to use\n\nInclude jQuery and Mvalidate.js;\n\n```html\n  \u003cscript src=\"http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js\"\u003e\u003c/script\u003e\n  \u003cscript src=\"path/to/Mvalidate.js\"\u003e\u003c/script\u003e\n```\nExample:\n```html\n\u003cform\u003e\n\t\u003cinput type=\"text\" data-vali=\"email\" name=\"email\" /\u003e\n\u003c/form\u003e\n```\n\n```javascript\nvar validateForm = new Malidate($(\"form\"));\n.....other code .......\n    if (validateForm.validate()) {\n        // todo something\n        // 如果验证通过返回表单数据，可通过validateForm.data获取\n        // 否则返回false\n    }\n...... other code .....\n```\n\n#API与使用说明\n\n自带验证规则： number, email, mobile(只验证手机号) ,tel(可通时时验证手机、座机、400、800服务号),password, notNull, url\n\n1. ［data-vali］－－ 验证规则；  \n   ［name］－－ 表单键值名， 不设置该属性不影响验证。但是返回的表单数据中将不包含该项。  \n\n2. 验证函数： .validate(option)  \n    @option:  null 不传入option时，验证所有项；   \n        {array} 传入数组时验证数组中包含项；  \n        {string} 传入string时只验证单项;   \n\n3. 添加验证规则： .addValidations(object) \n\n```javascript\n.addValidations({\n    IDcard: function(v) {\n        // v表单需验证值\n        if ( !v.length ) {\n            return false;\n        }\n\n        var r = /(^\\d{15}$)|(^\\d{17}([0-9]|X)$)/;\n        return r.test(v);\n    }\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaelweb%2Fmvalidate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaelweb%2Fmvalidate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaelweb%2Fmvalidate/lists"}