{"id":19017029,"url":"https://github.com/alchaplinsky/ajaxform","last_synced_at":"2025-04-23T02:48:52.409Z","repository":{"id":3678816,"uuid":"4748493","full_name":"alchaplinsky/ajaxform","owner":"alchaplinsky","description":"ajaxForm jQuery plugin for submitting and validating forms via AJAX","archived":false,"fork":false,"pushed_at":"2013-05-26T11:19:23.000Z","size":158,"stargazers_count":7,"open_issues_count":0,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T02:48:46.937Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/alchapone/ajaxform","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alchaplinsky.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":"2012-06-22T07:11:22.000Z","updated_at":"2024-07-03T19:26:12.000Z","dependencies_parsed_at":"2022-08-18T23:51:57.820Z","dependency_job_id":null,"html_url":"https://github.com/alchaplinsky/ajaxform","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fajaxform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fajaxform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fajaxform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fajaxform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alchaplinsky","download_url":"https://codeload.github.com/alchaplinsky/ajaxform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360249,"owners_count":21417717,"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-08T19:45:33.089Z","updated_at":"2025-04-23T02:48:52.389Z","avatar_url":"https://github.com/alchaplinsky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AjaxForm Plugin\n\n\nThis is jQuery plugin that helps submiting and validating your forms asynchronously. \nKeep your validation logic on server side, and for client side validate with javascript and AJAX.\n\n## Usage\n\nUsing ajaxForm plugin is fairly easy:\n\nJust include plugin script into `head` section within `script` tag. And then call:\n\n``` javascript\n  $('#form').ajaxForm();\n```\nOptionaly ajaxFom function takes a hash of paratmeters:\n\n``` javascript\n  $('#form').ajaxForm({\n    errorClass: 'error-field', // Error class applied to field if it failed validation\n    showErrorMessage: true,    // Show error messages or just highlight field \n    errorMessageFormat: '\u003cdiv class=\"error-message\"\u003e{message}\u003c/div\u003e', // Error message markup.\n    insertMessage: 'before',   // Error message position. Accepts 2 options 'before' and 'after'\n    onSuccess: function(){},     // Success callback. If validation passed\n    onErrors: function(){},  //is callback for successfull server response with array of validation errors\n    onError: function(){},  //is server error callback\n  });\n```\n\nOr a single success callback function:\n\n``` javascript\n  $('#form').ajaxForm(function(){\n    document.location.href = '/some_url';\n  });\n```\n\nOptionaly you can specify `redirect`  option in server response. So if JSON response contains `redirect: '/some_url'` \nit would be automaticaly triggered without any additional callbacks or configuration\n\n## Backend\n\nIn order to make ajaxForm correctly apply validation errors to form, server should respond with JSON containing errors in speified format.\n\n### Response example with errors:\n\n```js\n  {errors: {email: \"Invalid email format\", username: \"Username is already taken\"}}\n```\n\nMultiple errors can be specified to the same field. But only the first one will be shown as an error message.\n\n```js\n  {errors: {phone: [\"Phone is too short\", \"Phone should be in numeric format\"]}}\n```\n\n### Ruby on Rails\n\nIf you are using Rails, generating error hash is as simple as:\n\n```ruby\n  render :json =\u003e {:errors =\u003e @model.errors}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Fajaxform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falchaplinsky%2Fajaxform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Fajaxform/lists"}