{"id":16057558,"url":"https://github.com/aduth/jquery.imposeformat","last_synced_at":"2026-06-08T16:31:19.466Z","repository":{"id":10377872,"uuid":"12523023","full_name":"aduth/jquery.imposeFormat","owner":"aduth","description":"Unobtrusively impose a consistent format on form inputs","archived":false,"fork":false,"pushed_at":"2014-01-15T00:55:04.000Z","size":264,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T22:35:06.648Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aduth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-01T16:04:59.000Z","updated_at":"2014-01-15T00:55:05.000Z","dependencies_parsed_at":"2022-08-30T12:01:19.918Z","dependency_job_id":null,"html_url":"https://github.com/aduth/jquery.imposeFormat","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aduth/jquery.imposeFormat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fjquery.imposeFormat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fjquery.imposeFormat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fjquery.imposeFormat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fjquery.imposeFormat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aduth","download_url":"https://codeload.github.com/aduth/jquery.imposeFormat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fjquery.imposeFormat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34071651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"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":[],"created_at":"2024-10-09T03:03:27.832Z","updated_at":"2026-06-08T16:31:19.448Z","avatar_url":"https://github.com/aduth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jQuery.imposeFormat\n\nImposeFormat is a jQuery plugin which unobtrusively imposes a consistent format on form inputs. Specifically, it can rewrite user inputs for dates, times, phone numbers, or credit card numbers to a consistent format.\n\n[Refer to the test fixtures for simple use cases demonstrating plugin behavior](https://github.com/aduth/jquery.imposeFormat/blob/master/test/spec/test.imposeFormat.js#L156-L193)\n\n## Usage\n\nInclude jQuery and jquery.imposeFormat using script tags. Then, when the page is loaded, call imposeFormat on either individual inputs or an entire form.\n\n### With individual inputs\n\nAdd `data-impose` attribute to each input field or specify a type when calling imposeFormat. Current default formats are **date**, **time**, **phone**, and **creditcard**. Optionally, when calling imposeFormat, you can include your own search and replace values.\n\n```html\n\u003cinput id=\"myTime\" type=\"text\" data-impose=\"time\"\u003e\n\u003cscript\u003e\n$(document).ready(function() {\n  $('#myTime').imposeFormat();\n  // OR: $('#myTime').imposeFormat({ type: 'time' });\n  // OR: $('#myTime').imposeFormat({\n  //       pattern: {\n  //         search: /^(0\\d|1[0-2]|\\d):?([0-5]\\d)[ ]*(AM?|PM?)$/i,\n  //         replacement: '[0$1]{-2}:[0$2]{-2} [$3M]{2U}'\n  //       }\n  //     });\n});\n\u003c/script\u003e\n```\n\nIn this case, whenever the value of the text field is changed, the date will be rewritten to be delimited with slashes by default (e.g. \"12-31-1969\" to \"12/31/1969\"). This accomodates a user entering the date with whichever delimiters they're most comfortable with.\n\njQuery.imposeFormat is *not* a validation plugin. If the user leaves the field blank or enters a value which does not match the search, imposeFormat *will do nothing*. You should always perform additional server-side validation.\n\n### With entire form\n\n```html\n\u003cform id=\"myForm\"\u003e\n  \u003cinput type=\"text\" data-impose=\"time\"\u003e\n  \u003cinput type=\"text\" data-impose=\"date\"\u003e\n\u003c/form\u003e\n\u003cscript\u003e\n$(document).ready(function() {\n  $('#myForm').imposeFormat();\n});\n\u003c/script\u003e\n```\n\n## Options\n\nNote that, by default, date and time replacements use North American date standards.\n\nYou can create your own search and replace strings either when calling imposeFormat on an individual element (see *Usage* section), or by overriding the default patterns object[[1]](https://github.com/aduth/jquery.imposeFormat/blob/master/src/jquery.imposeFormat.js#L29-L46).\n\nThe search value is a simple regular expression object. The replacement string is a non-standard custom syntax with the following definition:\n\n* Each replacement group is denoted by an opening and closing square bracket i.e. [ ]\n* The replacement value is denoted by a dollar sign followed by the replacement index i.e. $3 (standard RegExp)\n* Special options (optional) are denoted by an opening and closing curly bracket following the replacement group i.e { }\n * Slice from beginning with a positive number, or from end using a negative number i.e. {-2}\n * Change case using U (upper) or L (flags) i.e. {U}\n\n_Example: Time_\n\n```javascript\ntime: {\n  search: /^(0\\d|1[0-2]|\\d):?([0-5]\\d)[ ]*(AM?|PM?)$/i,\n  replacement: '[0$1]{-2}:[0$2]{-2} [$3M]{2U}'\n}\n```\n\n## License\n\nCopyright (c) 2013 Andrew Duthie\n\nReleased under the MIT License (see LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faduth%2Fjquery.imposeformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faduth%2Fjquery.imposeformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faduth%2Fjquery.imposeformat/lists"}