{"id":37902352,"url":"https://github.com/loadingio/ldform","last_synced_at":"2026-01-16T17:05:35.530Z","repository":{"id":41953049,"uuid":"186518038","full_name":"loadingio/ldform","owner":"loadingio","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-19T05:26:25.000Z","size":147,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T23:41:36.794Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"LiveScript","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/loadingio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-05-14T00:59:18.000Z","updated_at":"2022-01-19T15:07:47.000Z","dependencies_parsed_at":"2023-01-23T11:25:14.419Z","dependency_job_id":null,"html_url":"https://github.com/loadingio/ldform","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/loadingio/ldform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loadingio","download_url":"https://codeload.github.com/loadingio/ldform/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-16T17:05:34.562Z","updated_at":"2026-01-16T17:05:35.522Z","avatar_url":"https://github.com/loadingio.png","language":"LiveScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ldform\n\nForm validation helper\n\n\n## Usage\n\n    form = new ldform(config);\n\n\nldform automatically scan every input fields by `\\*[name]` selector, so you must provide name attributes for each input or .form-control element:\n\n    \u003cinput type=\"text\" name=\"username\"/\u003e\n    \u003ctextarea class=\"form-control\" name=\"description\"/\u003e\n\nOr, you can specify your own `getFields` function to apply your own rules.\n\nAdditionally, if you have an element with its type being 'submit', ldform will automatically remove it's 'disabled' class when validation passed. You can overwrite this behavior by manually specify a submit element with `submit` option.\n\nFor nested form, simply add a `ldform` attribute as scoping element to separate them:\n\n    \u003cdiv ldform\u003e\n      \u003cinput name=\"a\"\u003e\n      \u003cdiv ldform\u003e\n        \u003c!-- b is scoped and won't be handled, unless we have another ldform over #form2 --\u003e\n        \u003cinput name=\"b\"\u003e\n      \u003c/form\u003e\n    \u003c/form\u003e\n\n\n## Configurations\n\n * root: base element for this form. HTMLElement or CSS Selector. Required.\n * init(): init function.\n * verify(name, value, element): validation function.\n   * input:\n     * name: field name\n     * value: field value\n     * element: field element\n   * returns: status value ( see Status Object below )\n   * optional. if omitted, ldform will check against emptiness.\n * getFields(root): customized rules for getting fields.\n   input: root - root element for ldform\n   return: fields object ( see below )\n   if omitted, default to use selector `\\*[name]`\n   \n * names(status, fields): return list of name for fields to check. if omitted, default to all fields.\n   * input:\n     * status: status object, see below\n     * fields: field elements object.\n * afterCheck(status, fields): custom function for doing anything after check\n   * input: see below\n * debounce(n, s): should check call debounce?\n   * input\n     * n - event field name\n     * s - status object\n   * returns: true (debounce) / false (no debounce)\n * values: hash object with default values for corresponding keys.\n * submit: specify the element to be un-disabled when form is validated.\n * initCheck: force a checkAll at initialization.\n\n\n## Status Object\n\nAn object with each key corresponding to a field and value of that key corresponding to field status. For example:\n\n    {\n        \"name\": 0,\n        \"password\": 2,\n        \"recaptcha\": 3,\n        \"newsletter\": 1\n    }\n\nThe values have following meaning:\n\n * 0 - valid\n * 1 - untouched ( not yet edit )\n * 2 - invalid\n * 3 - editing\n * 4 ~ 9 - preserved\n * 10 and above - user defined.\n\n\n## Fields Object\n\nAn object containing fields elements, such as:\n\n    {\n        \"name\": ...,\n        \"password\": ...,\n        \"recaptcha\": ...,\n        \"newsletter\": ...\n    }\n\n\n## Methods\n\n - `ready()`: return true if form is valid and ready to engage.\n - `check({n, now})`: check fields for all touched fields. if n is provided, touch the field named n.\n   if now = true, check immediately without debouncing.\n   to check multiple fields, provide a list:\n\n       check([{...}, {...}, ... ])\n\n - `values(o)`\n   - without parameter: get values for all fields with a name.\n   - else: param should be a hash object with name - value pairs for each fields.\n - `on(event-name, cb)`: listen to event \"event-name\" by callback cb. current supported event:\n   - readystatechange: (is-ready) - fired if ready state is changed.\n - `reset()`: clear form fields and reset status ( clear is-invalid  / is-valid classes )\n - `field(n)`: get input field with name 'n'\n - `checkAll()`: force check all fields immediately. useful in programmatically input fields.\n   - set initCheck config to true for a shorthand check on initialization.\n - `getfd()`: get FormData object corresponding to all fields in this form.\n\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floadingio%2Fldform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floadingio%2Fldform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floadingio%2Fldform/lists"}