{"id":17925496,"url":"https://github.com/scottbedard/jquery-validator","last_synced_at":"2025-08-12T05:14:48.623Z","repository":{"id":26353901,"uuid":"29802883","full_name":"scottbedard/jquery-validator","owner":"scottbedard","description":"jQuery validation using Laravel rules.","archived":false,"fork":false,"pushed_at":"2015-01-25T08:14:32.000Z","size":164,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-02T14:56:00.322Z","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/scottbedard.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":"2015-01-25T04:40:39.000Z","updated_at":"2015-01-25T08:13:28.000Z","dependencies_parsed_at":"2022-08-28T01:00:37.629Z","dependency_job_id":null,"html_url":"https://github.com/scottbedard/jquery-validator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/scottbedard/jquery-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fjquery-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fjquery-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fjquery-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fjquery-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scottbedard","download_url":"https://codeload.github.com/scottbedard/jquery-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottbedard%2Fjquery-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270005591,"owners_count":24510939,"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-12T02:00:09.011Z","response_time":80,"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-28T20:56:18.061Z","updated_at":"2025-08-12T05:14:48.591Z","avatar_url":"https://github.com/scottbedard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jQuery Validator\nThe goal of this tool is to mimic [Laravel validation](http://laravel.com/docs/validation) as closely as possible with jQuery. By doing this, you no longer have to worry about keeping the server and client validation synchronized. Just write your rules once, and move on to more important things. To get started, JSON encode your rules and place them in a form's ```data-validation``` attribute. From there, simply call ```validate()``` to see if everything checks out!\n\n### Supported validation\nFor a list of available validation rules, check out the [Laravel documentation](http://laravel.com/docs/validation). There are a few rules that are not supported at this time. Unsupported rules include ```active_url```, ```array```, ```exists```, ```image```, ```mimes```, ```timezone```, ```unique```, ```url```, custom rules, and file validation.\n\n### Basic usage\nFirst thing's first, we need some validation rules\n```php\n$rules = [\n    'first_name'    =\u003e 'required|alpha',\n    'last_name'     =\u003e 'required|alpha',\n    'email'         =\u003e 'required|email',\n    'age'           =\u003e 'integer|min:18',\n    'terms'         =\u003e 'accepted'\n];\n\n$dataValidation = htmlspecialchars(json_encode($rules));\n```\nNext lets build up our form, and attach our rules.\n```html\n\u003cform action=\"#\" id=\"signup\" data-validation=\"\u003c?= $dataValidation ?\u003e\"\u003e\n    \u003cinput type=\"text\" name=\"first_name\" placeholder=\"First name\" /\u003e\n    \u003cinput type=\"text\" name=\"last_name\" placeholder=\"Last name\" /\u003e\n    \u003cinput type=\"text\" name=\"email\" placeholder=\"Email address\" /\u003e\n    \u003cinput type=\"text\" name=\"age\" placeholder=\"Age\" /\u003e\n    \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\nNow for the fun part, lets validate our form and let the user know if they've messed up.\n```javascript\n$(function() {\n\n    $('#signup').submit(function(event) {\n    \n        var validationError = $(this).validate(1)\n        \n        if (validationError) {\n            event.preventDefault()\n            alert (validationError)\n        }\n        \n    })\n    \n})\n```\nFinished, we now have client side validation running off the same rules governing the server side validation! The ```1``` value passed to ```validate()``` simply references how many error messages to return. If this is left out or set to zero, all errors will be returned.\n\n### Custom messages\nLets make the above example just a little bit fancier with some custom error messages. To do this, simply take the error messages array from your Laravel validation and plug it into the form.\n```php\n$messages = [\n    'age.min'           =\u003e 'Sorry, you must be 18 years of age to sign up.',\n    'terms.accepted'    =\u003e 'You must accept the terms of service.'\n];\n\n$dataMessages = htmlspecialchars(json_encode($messages));\n```\n```html+php\n\u003cform action=\"#\" id=\"signup\"\n    data-validation=\"\u003c?= $dataValidation ?\u003e\"\n    data-validation-messages=\"\u003c?= $dataMessages ?\u003e\"\n\u003e\n    ...\n\u003c/form\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottbedard%2Fjquery-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottbedard%2Fjquery-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottbedard%2Fjquery-validator/lists"}