{"id":20819961,"url":"https://github.com/elo7/form-amd","last_synced_at":"2025-08-19T11:14:04.227Z","repository":{"id":48311145,"uuid":"47577365","full_name":"elo7/form-amd","owner":"elo7","description":"form.js is a small library to help form manipulation and validation. This library uses amd structure.","archived":false,"fork":false,"pushed_at":"2021-08-02T08:31:03.000Z","size":76,"stargazers_count":7,"open_issues_count":7,"forks_count":3,"subscribers_count":96,"default_branch":"master","last_synced_at":"2025-08-07T17:02:25.129Z","etag":null,"topics":["amd","dom","form","front-end","javascript","lib","martell","nymeros"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elo7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T20:27:56.000Z","updated_at":"2024-01-11T19:12:23.000Z","dependencies_parsed_at":"2022-08-24T06:01:24.134Z","dependency_job_id":null,"html_url":"https://github.com/elo7/form-amd","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/elo7/form-amd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fform-amd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fform-amd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fform-amd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fform-amd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elo7","download_url":"https://codeload.github.com/elo7/form-amd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fform-amd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271143398,"owners_count":24706346,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["amd","dom","form","front-end","javascript","lib","martell","nymeros"],"created_at":"2024-11-17T22:07:55.887Z","updated_at":"2025-08-19T11:14:04.200Z","avatar_url":"https://github.com/elo7.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Form-amd\n\n_Form-amd library_\n\nform.js is a small library to help form manipulations and validation. This library uses [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) structure.\n\n[![Build Status](https://travis-ci.org/elo7/form-amd.svg?branch=master)](https://travis-ci.org/elo7/form-amd)\n\nIt uses html5 form attributes validate specification and works on browsers that does not support html5 validation.\nThen, we built it from scratch.\n\n## Installation\n\nInstall with [npm](https://www.npmjs.com): `npm install elo7-form-amd`\n\n## Dependencies\n\nForm-amd depends on an [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) implementation. We suggest [async-define](https://gist.github.com/sergiolopes/5778124) implementation for dependency lookup.\nForm-amd also depends on [doc-amd](https://github.com/elo7/doc-amd).\n\n## Methods\n\n#### submitOnChange\n`.submitOnChange(selectorOrDocElement[, callback])`\n\n###### Description:\nSubmit the parent form when event **change** is triggered.\n\n###### Parameters:\n\u003e selectorOrDocElement: doc-amd object or String //A CSS selector. Note that, if it is a class name with dots, the dots must be escaped. E.g.: doc(\".my\\\\\\\\.class\")\n\n\u003e callback: Function() //A function to call before the event is triggered\n\n###### Sample:\n``` js\ndefine(['form'], function(form) {\n  form.submitOnChange($('#country')); //Submit the parent form when the country is selected\n  form.submitOnChange('#country', function(){...}); //Run the callback function and then submit the parent form when the country is selected\n});\n```\n\n#### submitOnBlur\n`.submitOnBlur(selector)`\n\n###### Description:\nSubmit the parent form when event **blur** is triggered.\n\n###### Parameters:\n\u003e selector: String\n\n###### Sample:\n``` js\ndefine(['form'], function(form) {\n  form.submitOnBlur('#name'); //Submit the parent form when the form element loses focus\n});\n```\n\n#### focus\n`.focus(selector)`\n\n###### Description:\nFocus on selected element. If the device is mobile, it calls **scrollIntoView** function.\n\n###### Parameters:\n\u003e selector: String\n\n###### Sample:\n``` js\ndefine(['form'], function(form) {\n  form.focus('#input'); //Focus on the element #input\n});\n```\n\n#### validate\n`.validate(selectorOrDocElement[, object])`\n\n###### Description:\nValidate the form using almost all the html5 attributes validate spec.\n\n###### Parameters:\n\u003e selectorOrDocElement: doc-amd object or String //A CSS selector. Note that, if it is a class name with dots, the dots must be escaped. E.g.: doc(\".my\\\\\\\\.class\")\n\n\u003e object: Object //An object with the properties _messages_ (\"required\", \"min\", \"maxlength\", \"pattern\" or \"email\"), _success_ (function callback) or _error_ (function callback)\n\n###### Sample:\n``` js\ndefine(['form'], function(form) {\n  form.validate($('#form')); //Validate the form with default messages\n  form.validate('#form', {\n    messages: {\n      'required': 'Field required.',\n      'min': 'Enter a value greater than or equal to {0}.',\n      'maxlength': 'Enter a value with max length less than or equal to {0}.',\n      'pattern': 'Enter a valid value.',\n      'email': 'Enter a valid email address.'\n    }, //Validate the form with this messages\n    success: function(){\n      // success callback\n    },\n    error: function(){\n      // error callback\n    }\n  });\n});\n```\n\n###### Default messages:\n``` txt\n required: This field is required\n min: Please enter a value greater than or equal to {0}\n maxlength: Please enter a value with max length less than or equal to {0}\n pattern: Please enter a valid value\n email: Please enter a valid email address\n```\n\n#### appendMessage\n`.append(selector, text)`\n\n###### Description:\nAppend validation messages\n\n###### Parameters:\n\u003e selector: String\n\n\u003e text: String\n\n###### Sample:\n``` js\ndefine(['form'], function(form) {\n  form.append('label[for=\"date\"]', 'dd/mm/yyyy'); //This will append \u003cspan class=\"message\"\u003edd/mm/yyyy\u003c/span\u003e. Note that this element will be removed when the user starts to type another value.\n});\n```\n\n#### removeValidationErrors\n`.removeValidationErrors(selector)`\n\n###### Description:\nRemoves all validation messages from selected form\n\n###### Parameters:\n\u003e selector: String\n\n###### Sample:\n``` js\ndefine(['form'], function(form) {\n  form.removeValidationErrors('#form'); //This will remove all validation messages appended\n});\n```\n\n## License\n\nForm-amd is released under the [BSD](https://github.com/elo7/form-amd/blob/master/LICENSE). Have at it.\n\n* * *\n\nCopyright :copyright: 2019 Elo7# form-amd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felo7%2Fform-amd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felo7%2Fform-amd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felo7%2Fform-amd/lists"}