From 29f85e4a558a79bdf5c7972dbbff2c165706b786 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 09:54:34 +0000 Subject: [PATCH 01/22] Add GitHub Pages configuration with Jekyll Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/56c60609-42d5-4470-b53a-8ba170e29227 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- .github/workflows/deploy-pages.yml | 56 +++ Gemfile | 22 + _config.yml | 37 ++ contribute.md | 12 + documentation.md | 213 +++++++++ index.md | 50 ++ package-lock.json | 725 +++++++++++++++++++++-------- reference.md | 130 ++++++ 8 files changed, 1043 insertions(+), 202 deletions(-) create mode 100644 .github/workflows/deploy-pages.yml create mode 100644 Gemfile create mode 100644 _config.yml create mode 100644 contribute.md create mode 100644 documentation.md create mode 100644 index.md create mode 100644 reference.md diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml new file mode 100644 index 0000000..dd2a954 --- /dev/null +++ b/.github/workflows/deploy-pages.yml @@ -0,0 +1,56 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + - master + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + bundler-cache: true + + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f809cbc --- /dev/null +++ b/Gemfile @@ -0,0 +1,22 @@ +source "https://rubygems.org" + +gem "jekyll", "~> 4.3" +gem "minima", "~> 2.5" + +group :jekyll_plugins do + gem "jekyll-feed", "~> 0.12" +end + +# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem +# and associated library. +platforms :mingw, :x64_mingw, :mswin, :jruby do + gem "tzinfo", ">= 1", "< 3" + gem "tzinfo-data" +end + +# Performance-booster for watching directories on Windows +gem "wdm", "~> 0.1", :platforms => [:mingw, :x64_mingw, :mswin] + +# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem +# do not have a Java counterpart. +gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..91d9780 --- /dev/null +++ b/_config.yml @@ -0,0 +1,37 @@ +title: jQuery Validation Plugin +description: Site content for the jQuery Validation Plugin +url: https://jqueryvalidation.org +baseurl: "" + +# Build settings +markdown: kramdown +theme: minima + +# Exclude from processing +exclude: + - Gruntfile.js + - package.json + - package-lock.json + - node_modules + - config.json + - config-sample.json + - entries2html.xsl + - notes.xsl + - README.md + - LICENSE-MIT.txt + - .gitignore + - .gitattributes + - dist + +# Collections +collections: + entries: + output: true + permalink: /:collection/:name/ + +defaults: + - scope: + path: "" + type: "entries" + values: + layout: "default" diff --git a/contribute.md b/contribute.md new file mode 100644 index 0000000..375c197 --- /dev/null +++ b/contribute.md @@ -0,0 +1,12 @@ +--- +layout: default +title: Contribute +--- + +There are several ways for you to contribute to this plugin: + +* Help [with the code](https://github.com/jquery-validation/jquery-validation/). Fix bugs, propose features, translate messages and methods... +* Help [with the site content](https://github.com/jquery-validation/validation-content). Improve API documentation, examples, references... +* Help [with the site theme](https://github.com/jquery-validation/validation-theme). This is a WordPress theme that still needs a lot of improvements. + +The majority of contributions can be viewed under [jQuery's contribute site](https://contribute.jquery.org/) - the style guides et al apply to this project as well. diff --git a/documentation.md b/documentation.md new file mode 100644 index 0000000..da0293a --- /dev/null +++ b/documentation.md @@ -0,0 +1,213 @@ +--- +layout: default +title: Documentation +--- + +# Validate forms like you've never validated before! + +**"But doesn't jQuery make it easy to write your own validation plugin?"** +Sure, but there are still a lot of subtleties to take care of: You need a standard library of validation methods (such as emails, URLs, credit card numbers). You need to place error messages in the DOM and show and hide them when appropriate. You want to react to more than just a submit event, like keyup and blur. +You may need different ways to specify validation rules according to the server-side enviroment you are using on different projects. And after all, you don't want to reinvent the wheel, do you? + +**"But aren't there already a ton of validation plugins out there?"** +Right, there are a lot of non-jQuery-based solutions (which you'd avoid since you found jQuery) and some jQuery-based solutions. This particular one is one of the oldest jQuery plugins (started in July 2006) and has proved itself in projects all around the world. There is also an [article](http://bassistance.de/2007/07/04/about-client-side-form-validation-and-frameworks/) discussing how this plugin fits the bill of the should-be validation solution. + +Not convinced? [Have a look at this example](https://jqueryvalidation.org/files/demo/): + +

+
+
+ Please provide your name, email address (won't be published) and a comment +

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

+
+
+ +
+ +### Isn't that nice and easy? +A single line of jQuery to select the form and apply the validation plugin, plus a few annotations on each element to specify the validation rules. + +Of course that isn't the only way to specify rules. You also don't have to rely on those default messages, but they come in handy when starting to setup validation for a form. + +### A few things to look out for when playing around with the demo + +* After trying to submit an invalid form, the first invalid element is focused, allowing the user to correct the field. If another invalid field - that wasn't the first one - was focused before submit, that field is focused instead, allowing the user to start at the bottom if he or she prefers. +* Before a field is marked as invalid, the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages - they won't get bugged before having the chance to actually enter a correct value +* Once a field is marked invalid, it is eagerly validated: As soon as the user has entered the necessary value, the error message is removed +* If the user enters something in a non-marked field, and tabs/clicks away from it (blur the field), it is validated - obviously the user had the intention to enter something, but failed to enter the correct value + +That behaviour can be irritating when clicking through demos of the validation plugin - it is designed for an unobtrusive user experience, annoying the user as little as possible with unnecessary error messages. So when you try out other demos, try to react like one of your users would, and see if the behaviour is better then. If not, please let me know about any ideas you may have for improvements! + +# API Documentation + +You're probably looking for + +### [Options for the validate() method](/validate) + +If not, read on. + +Throughout the documentation, two terms are used very often, so it's important that you know their meaning in the context of the validation plugin: + +* **method**: A validation method implements the logic to validate an element, like an email method that checks for the right format of a text input's value. A set of standard methods is available, and it is easy to write your own. +* **rule**: A validation rule associates an element with a validation method, like "validate input with name "primary-mail" with methods "required" and "email". + +## Plugin methods + +This library adds three jQuery plugin methods, the main entry point being the `validate` method: + +* [`validate()` - Validates the selected form.](/validate) +* [`valid()` - Checks whether the selected form or selected elements are valid.](/valid) +* [`rules()` - Read, add and remove rules for an element.](/rules) + +## Custom selectors + +This library also extends jQuery with three custom selectors: + +* [`:blank` - Selects all elements with a blank value.](/blank-selector) +* [`:filled` - Selects all elements with a filled value.](/filled-selector) +* [`:unchecked` - Selects all elements that are unchecked.](/unchecked-selector) + +## Validator + +The validate method returns a Validator object that has a few public methods that you can use to trigger validation programmatically or change the contents of the form. The validator object has more methods, but only those documented here are intended for usage. + +* [`Validator.form()` - Validates the form.](/Validator.form) +* [`Validator.element()` - Validates a single element.](/Validator.element) +* [`Validator.resetForm()` - Resets the controlled form.](/Validator.resetForm) +* [`Validator.showErrors()` - Show the specified messages.](/Validator.showErrors) +* [`Validator.numberOfInvalids()` - Returns the number of invalid fields.](/Validator.numberOfInvalids) +* [`Validator.destroy()` - Destroys this instance of validator.](/Validator.destroy) + +There are a few static methods on the validator object: + +* [`jQuery.validator.addMethod()` - Add a custom validation method.](/jQuery.validator.addMethod) +* [`jQuery.validator.format()` - Replaces {n} placeholders with arguments.](/jQuery.validator.format) +* [`jQuery.validator.setDefaults()` - Modify default settings for validation.](/jQuery.validator.setDefaults) +* [`jQuery.validator.addClassRules()` - Add a compound class method.](/jQuery.validator.addClassRules) + +## List of built-in Validation methods + +A set of standard validation methods is provided: + +* [`required` - Makes the element required.](/required-method) +* [`remote` - Requests a resource to check the element for validity.](/remote-method) +* [`minlength` - Makes the element require a given minimum length.](/minlength-method) +* [`maxlength` - Makes the element require a given maximum length.](/maxlength-method) +* [`rangelength` - Makes the element require a given value range.](/rangelength-method) +* [`min` - Makes the element require a given minimum.](/min-method) +* [`max` - Makes the element require a given maximum.](/max-method) +* [`range` - Makes the element require a given value range.](/range-method) +* [`step` - Makes the element require a given step.](/step-method) +* [`email` - Makes the element require a valid email](/email-method) +* [`url` - Makes the element require a valid url](/url-method) +* [`date` - Makes the element require a date.](/date-method) +* [`dateISO` - Makes the element require an ISO date.](/dateISO-method) +* [`number` - Makes the element require a decimal number.](/number-method) +* [`digits` - Makes the element require digits only.](/digits-method) +* [`equalTo` - Requires the element to be the same as another one](/equalTo-method) + +Some more methods are provided as add-ons, and are currently included in additional-methods.js in the download package. Not all of them are documented here: + +* [`accept` - Makes a file upload accept only specified mime-types.](/accept-method) +* [`creditcard` - Makes the element require a credit card number.](/creditcard-method) +* [`extension` - Makes the element require a certain file extension.](/extension-method) +* [`phoneUS` - Validate for valid US phone number.](/phoneUS-method) +* [`require_from_group` - Ensures a given number of fields in a group are complete.](/require_from_group-method) + +You can find the [source code for all additional methods in the GitHub repository](https://github.com/jzaefferer/jquery-validation/tree/master/src/additional). + +It is possible to re-define the implementation of the built-in rules using the [`$.validator.methods` property](/jQuery.validator.methods/) + +# [General Guidelines](/reference) + +The General Guidelines section provides detailed discussion of the design and ideas behind the plugin, explaining why certain things are as they are. It covers the features in more detail than the API documentation, which just briefly explains the various methods and options available. + +If you've decided to use the validation plugin in your application and want to get to know it better, it is recommended that you read the guidelines. + +## Fields with complex names (brackets, dots) + +When you have a name attribute like user[name], make sure to put the name in quotes. More details in the [General Guidelines](/reference). + +## Too much recursion + +Another common problem occurs with this code: + +

+ $("#myform").validate({
+  submitHandler: function(form) {
+    // some other code
+    // maybe disabling submit button
+    // then:
+    $(form).submit();
+  }
+ });
+
+ +This results in a too-much-recursion error: $(form).submit() triggers another round of validation, resulting in another call to submitHandler, and voila, recursion. Replace that with form.submit(), which triggers the native submit event instead and not the validation. + +So the correct code looks slightly different: + +

+ $("#myform").validate({
+  submitHandler: function(form) {
+    form.submit();
+  }
+ });
+
+ +# Demos + +## [The Marketo sign-up form](https://jqueryvalidation.org/files/demo/marketo/) +### [The Marketo sign-up form, step 2](https://jqueryvalidation.org/files/demo/marketo/step2.htm) +Based on an old version of the marketo.com sign-up form. The custom validation was once replaced with this plugin. Thanks to Glen Lipka for contributing it! + +*Notable features of the demo:* + +* Customized message display: No messages displayed for the required method, only for typing-errors (like wrong email format); A summary is displayed at the top ("You missed 12 fields. They have been highlighted below.") +* Remote validation of email field. Try to enter eg. glen@marketo.com +* Integration with masked-input plugin, see Zip and Phone fields and Credit Card Number on step 2 +* A custom method for making the billing address on step 2 optional when "Same as Company Address" is checked +* A custom method for checking the password: Checks that the password contains at least one number and one character and that it is at least 6 characters long. If the user blurs the field with an invalid value, the input is emptied and gets focus again. + +## [The Remember The Milk sign-up form](https://jqueryvalidation.org/files/demo/milk/) +The sign-up form from rememberthemilk.com (based on an older version). The custom validation was replaced using this plugin. Thanks to RTM for contributing! + +*Notable features of the demo:* + +* Custom message display, based on the original table layout, using success option to display a checkmark for valid fields +* Remote validation of username, to check if it is already taken (try "Peter", "asdf" or "George") + +## [A multipart "buy&sell a house" form](https://jqueryvalidation.org/files/demo/multipart/) +Contributed by Michael Evangelista, showing a multipart form for buying and selling houses. + +*Notable features of the demo:* + +* Multipart, implemented using the jQuery UI accordion and a custom method to check if an element is on the current page when validated +* Integration with masked-input plugin, see Phone and Zip fields + +## [Using remote validation to help with captchas](https://jqueryvalidation.org/files/demo/captcha/) +Features remote validation for helping the user to fill out captchas. + +*Notable features of the demo:* + +* Remote validation to check if the user entered the correct captcha, without forcing him to submit the form first diff --git a/index.md b/index.md new file mode 100644 index 0000000..be9c2f1 --- /dev/null +++ b/index.md @@ -0,0 +1,50 @@ +--- +layout: default +title: jQuery Validation Plugin +--- + +This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you're building something new from scratch, but also when you're trying to integrate something into an existing application with lots of existing markup. The plugin comes bundled with a useful set of validation methods, including URL and email validation, while providing an API to write your own methods. All bundled methods come with default error messages in english and translations into 37 other languages. + +For a quick overview of what this plugin provides, check out this [Webucator](https://www.webucator.com/) video (they also provide [jQuery trainings](https://www.webucator.com/webdesign/jquery.cfm)): + + + +The plugin was initially written and maintained by [Jörn Zaefferer](http://bassistance.de/), a member of the [jQuery team](https://jquery.org/team), lead developer on the jQuery UI team and maintainer of QUnit. It was started back in the early days of jQuery in 2006, and updated and improved since then. + +Starting with Version 1.15.0 [Markus Staab](https://github.com/staabm) took over the maintenance of the codebase in February 2016. Since July 2016 [Brahim Arkni](https://github.com/Arkni) assisted Markus, and a few months later Brahim joined the jQuery Validation core team. + +**Current version:** 1.19.5 + +**License:** MIT + +### Files: +- [Download](https://github.com/jzaefferer/jquery-validation/releases/tag/1.19.5) - zip-Archive with source code, minified and packed version, demos and examples +- [Changelog](https://github.com/jzaefferer/jquery-validation/releases/tag/1.19.5) +- [Demos](//jqueryvalidation.org/files/demo/) +- [Documentation](/documentation/) +- [GitHub Repository](https://github.com/jzaefferer/jquery-validation) + +### Installation via Package Managers +- Bower: `bower install jquery-validation` +- [NuGet](https://www.nuget.org/packages/jquery.validation): `Install-Package jQuery.Validation` +- [NPM](https://www.npmjs.com/package/jquery-validation): `npm i jquery-validation` + +### [Latest files on jsDelivr CDN](https://www.jsdelivr.com/package/npm/jquery-validation) (hotlinking welcome): +- [https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.js](https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.js) +- [https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js](https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js) +- [https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/additional-methods.js](https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/additional-methods.js) +- [https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/additional-methods.min.js](https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/additional-methods.min.js) + +### [Latest files on cdnjs CDN](https://cdnjs.com/libraries/jquery-validate) (hotlinking welcome): +- [https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.js](https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.js) +- [https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js](https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js) +- [https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/additional-methods.js](https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/additional-methods.js) +- [https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/additional-methods.min.js](https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/additional-methods.min.js) + +### Dependencies +#### Required +- [jQuery, tested with 1.7.2, 1.8.3, 1.9.1, 1.11.1, 3.1.1](https://jquery.com) + +### Support +- Please post questions to the [official using jQuery Plugins Forum](https://forum.jquery.com/using-jquery-plugins), tagging your question with (at least) "validate". Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in a shorter time. +- Please post bug reports and other contributions (enhancements, features, eg. new validation methods) to the [GitHub issue tracker](https://github.com/jzaefferer/jquery-validation/issues) diff --git a/package-lock.json b/package-lock.json index cfbfc18..8f6eb9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,412 +1,733 @@ { "name": "jqueryvalidation-content", "version": "1.0.0", - "lockfileVersion": 1, - "dependencies": { - "abbrev": { + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "jqueryvalidation-content", + "version": "1.0.0", + "dependencies": { + "grunt": "0.4.5", + "grunt-jquery-content": "2.0.0" + } + }, + "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, - "argparse": { + "node_modules/argparse": { "version": "0.1.16", "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", "integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=", "dependencies": { - "underscore.string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", - "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=" - } + "underscore": "~1.7.0", + "underscore.string": "~2.4.0" + } + }, + "node_modules/argparse/node_modules/underscore.string": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", + "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=", + "engines": { + "node": "*" } }, - "async": { + "node_modules/async": { "version": "0.1.22", "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", - "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=" + "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", + "engines": { + "node": "*" + } }, - "cheerio": { + "node_modules/cheerio": { "version": "0.17.0", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.17.0.tgz", "integrity": "sha1-+lrkLMYBIRM9KW0LRtmDIV9yaOo=", "dependencies": { - "lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" - } + "CSSselect": "~0.4.0", + "dom-serializer": "~0.0.0", + "entities": "~1.1.1", + "htmlparser2": "~3.7.2", + "lodash": "~2.4.1" + }, + "engines": { + "node": ">= 0.6" } }, - "coffee-script": { + "node_modules/cheerio/node_modules/lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", + "engines": [ + "node", + "rhino" + ] + }, + "node_modules/coffee-script": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", - "integrity": "sha1-FQ1rTLUiiUNp7+1qIQHCC8f0pPQ=" + "integrity": "sha1-FQ1rTLUiiUNp7+1qIQHCC8f0pPQ=", + "deprecated": "CoffeeScript on NPM has moved to \"coffeescript\" (no hyphen)", + "bin": { + "cake": "bin/cake", + "coffee": "bin/coffee" + }, + "engines": { + "node": ">=0.4.0" + } }, - "colors": { + "node_modules/colors": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", - "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=" + "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", + "engines": { + "node": ">=0.1.90" + } }, - "core-util-is": { + "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, - "CSSselect": { + "node_modules/CSSselect": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/CSSselect/-/CSSselect-0.4.1.tgz", - "integrity": "sha1-+Kt+H4QYzmPNput713ioXX7EkrI=" + "integrity": "sha1-+Kt+H4QYzmPNput713ioXX7EkrI=", + "deprecated": "the module is now available as 'css-select'", + "dependencies": { + "CSSwhat": "0.4", + "domutils": "1.4" + } }, - "CSSwhat": { + "node_modules/CSSwhat": { "version": "0.4.7", "resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz", - "integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s=" + "integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s=", + "deprecated": "the module is now available as 'css-what'", + "engines": { + "node": "*" + } }, - "dateformat": { + "node_modules/dateformat": { "version": "1.0.2-1.2.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", - "integrity": "sha1-sCIMAt6YYXQztyhRz0fePfLNvuk=" + "integrity": "sha1-sCIMAt6YYXQztyhRz0fePfLNvuk=", + "engines": { + "node": "*" + } }, - "dom-serializer": { + "node_modules/dom-serializer": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.0.1.tgz", "integrity": "sha1-lYmCfx4y0iw3yCmtq9WbMkevjq8=", "dependencies": { - "domelementtype": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=" - } + "domelementtype": "~1.1.1", + "entities": "~1.1.1" } }, - "domelementtype": { + "node_modules/dom-serializer/node_modules/domelementtype": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=" + }, + "node_modules/domelementtype": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=" + "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "deprecated": "update to domelementtype@1.3.1" }, - "domhandler": { + "node_modules/domhandler": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.2.1.tgz", - "integrity": "sha1-Wd+dzSJ+gIs2Wuc+H2aErD2Ub8I=" + "integrity": "sha1-Wd+dzSJ+gIs2Wuc+H2aErD2Ub8I=", + "dependencies": { + "domelementtype": "1" + } }, - "domutils": { + "node_modules/domutils": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.4.3.tgz", - "integrity": "sha1-CGVRN5bGswYDGFDhdVFrr4C3Km8=" + "integrity": "sha1-CGVRN5bGswYDGFDhdVFrr4C3Km8=", + "dependencies": { + "domelementtype": "1" + } }, - "entities": { + "node_modules/entities": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" }, - "esprima": { + "node_modules/esprima": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", - "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=" + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=0.4.0" + } }, - "eventemitter2": { + "node_modules/eventemitter2": { "version": "0.4.14", "resolved": "http://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=" }, - "exit": { + "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=" + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "engines": { + "node": ">= 0.8.0" + } }, - "findup-sync": { + "node_modules/findup-sync": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.3.tgz", "integrity": "sha1-fz56l7gjksZTvwZYm9hRkOk8NoM=", "dependencies": { - "glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=" - }, - "lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" - }, - "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=" - } - } - }, - "getobject": { + "glob": "~3.2.9", + "lodash": "~2.4.1" + }, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/findup-sync/node_modules/glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dependencies": { + "inherits": "2", + "minimatch": "0.3" + }, + "engines": { + "node": "*" + } + }, + "node_modules/findup-sync/node_modules/lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", + "engines": [ + "node", + "rhino" + ] + }, + "node_modules/findup-sync/node_modules/minimatch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "deprecated": "Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue", + "dependencies": { + "lru-cache": "2", + "sigmund": "~1.0.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/getobject": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", - "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=" + "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=", + "engines": { + "node": ">= 0.8.0" + } }, - "gilded-wordpress": { + "node_modules/gilded-wordpress": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gilded-wordpress/-/gilded-wordpress-1.0.0.tgz", "integrity": "sha1-xqLn1wetWX2pMQdeAcL+iBtttaA=", "dependencies": { - "async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" - }, - "glob": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.0.6.tgz", - "integrity": "sha1-aVxQvdTi+1xdNwsJHziNNwfikac=" - }, - "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=" - }, - "minimatch": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", - "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=" - } - } - }, - "glob": { + "async": "~0.9.0", + "glob": "~4.0.6", + "wordpress": "~1.0.0" + } + }, + "node_modules/gilded-wordpress/node_modules/async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, + "node_modules/gilded-wordpress/node_modules/glob": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.0.6.tgz", + "integrity": "sha1-aVxQvdTi+1xdNwsJHziNNwfikac=", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dependencies": { + "graceful-fs": "^3.0.2", + "inherits": "2", + "minimatch": "^1.0.0", + "once": "^1.3.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/gilded-wordpress/node_modules/graceful-fs": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "deprecated": "please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js", + "dependencies": { + "natives": "^1.1.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/gilded-wordpress/node_modules/minimatch": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", + "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=", + "deprecated": "Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue", + "dependencies": { + "lru-cache": "2", + "sigmund": "~1.0.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/glob": { "version": "3.1.21", "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", "dependencies": { - "inherits": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=" - } + "graceful-fs": "~1.2.0", + "inherits": "1", + "minimatch": "~0.2.11" + }, + "engines": { + "node": "*" } }, - "graceful-fs": { + "node_modules/glob/node_modules/inherits": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", + "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=" + }, + "node_modules/graceful-fs": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=" + "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", + "deprecated": "please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js", + "engines": { + "node": ">=0.4.0" + } }, - "grunt": { + "node_modules/grunt": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/grunt/-/grunt-0.4.5.tgz", - "integrity": "sha1-VpN81RlDJK3/bSB2MYMqnWuk5/A=" + "integrity": "sha1-VpN81RlDJK3/bSB2MYMqnWuk5/A=", + "dependencies": { + "async": "~0.1.22", + "coffee-script": "~1.3.3", + "colors": "~0.6.2", + "dateformat": "1.0.2-1.2.3", + "eventemitter2": "~0.4.13", + "exit": "~0.1.1", + "findup-sync": "~0.1.2", + "getobject": "~0.1.0", + "glob": "~3.1.21", + "grunt-legacy-log": "~0.1.0", + "grunt-legacy-util": "~0.2.0", + "hooker": "~0.2.3", + "iconv-lite": "~0.2.11", + "js-yaml": "~2.0.5", + "lodash": "~0.9.2", + "minimatch": "~0.2.12", + "nopt": "~1.0.10", + "rimraf": "~2.2.8", + "underscore.string": "~2.2.1", + "which": "~1.0.5" + }, + "engines": { + "node": ">= 0.8.0" + } }, - "grunt-check-modules": { + "node_modules/grunt-check-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/grunt-check-modules/-/grunt-check-modules-1.0.0.tgz", - "integrity": "sha1-Y/9erkYTF5tKifaozTcfekAfd4I=" + "integrity": "sha1-Y/9erkYTF5tKifaozTcfekAfd4I=", + "engines": { + "node": ">=0.6.0" + }, + "peerDependencies": { + "grunt": "0.4.x" + } }, - "grunt-jquery-content": { + "node_modules/grunt-jquery-content": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/grunt-jquery-content/-/grunt-jquery-content-2.0.0.tgz", "integrity": "sha1-jVFDOs0z/n7VL9956gAxwCRSwII=", "dependencies": { - "async": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", - "integrity": "sha1-rDYTsdqb7RtHUQu0ZRuJMeRxRsc=" - }, - "which": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/which/-/which-1.0.5.tgz", - "integrity": "sha1-VjDWgZ3aaS8UZEYueVbLQsCEJzk=" - } - } - }, - "grunt-legacy-log": { + "async": "0.9.0", + "cheerio": "0.17.0", + "grunt-check-modules": "1.0.0", + "grunt-wordpress": "2.1.0", + "he": "0.5.0", + "highlight.js": "7.3.0", + "marked": "0.3.2", + "rimraf": "2.2.8", + "spawnback": "1.0.0", + "which": "1.0.5" + } + }, + "node_modules/grunt-jquery-content/node_modules/async": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", + "integrity": "sha1-rDYTsdqb7RtHUQu0ZRuJMeRxRsc=" + }, + "node_modules/grunt-jquery-content/node_modules/which": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/which/-/which-1.0.5.tgz", + "integrity": "sha1-VjDWgZ3aaS8UZEYueVbLQsCEJzk=", + "bin": { + "which": "bin/which" + }, + "engines": { + "node": "*" + } + }, + "node_modules/grunt-legacy-log": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-0.1.3.tgz", "integrity": "sha1-7ClCboAwIa9ZAp+H0vnNczWgVTE=", "dependencies": { - "lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" - }, - "underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=" - } - } - }, - "grunt-legacy-log-utils": { + "colors": "~0.6.2", + "grunt-legacy-log-utils": "~0.1.1", + "hooker": "~0.2.3", + "lodash": "~2.4.1", + "underscore.string": "~2.3.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/grunt-legacy-log-utils": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-0.1.1.tgz", "integrity": "sha1-wHBrndkGThFvNvI/5OawSGcsD34=", "dependencies": { - "lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=" - }, - "underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=" - } - } - }, - "grunt-legacy-util": { + "colors": "~0.6.2", + "lodash": "~2.4.1", + "underscore.string": "~2.3.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/grunt-legacy-log-utils/node_modules/lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", + "engines": [ + "node", + "rhino" + ] + }, + "node_modules/grunt-legacy-log-utils/node_modules/underscore.string": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", + "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", + "engines": { + "node": "*" + } + }, + "node_modules/grunt-legacy-log/node_modules/lodash": { + "version": "2.4.2", + "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", + "engines": [ + "node", + "rhino" + ] + }, + "node_modules/grunt-legacy-log/node_modules/underscore.string": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", + "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", + "engines": { + "node": "*" + } + }, + "node_modules/grunt-legacy-util": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-0.2.0.tgz", - "integrity": "sha1-kzJIhNv343qf98Am3/RR2UqeVUs=" + "integrity": "sha1-kzJIhNv343qf98Am3/RR2UqeVUs=", + "dependencies": { + "async": "~0.1.22", + "exit": "~0.1.1", + "getobject": "~0.1.0", + "hooker": "~0.2.3", + "lodash": "~0.9.2", + "underscore.string": "~2.2.1", + "which": "~1.0.5" + }, + "engines": { + "node": ">= 0.8.0" + } }, - "grunt-wordpress": { + "node_modules/grunt-wordpress": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/grunt-wordpress/-/grunt-wordpress-2.1.0.tgz", - "integrity": "sha1-ty0EttVbQdFP/Yrq8W0ibFk9vl0=" + "integrity": "sha1-ty0EttVbQdFP/Yrq8W0ibFk9vl0=", + "dependencies": { + "gilded-wordpress": "1.0.0" + } }, - "he": { + "node_modules/he": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/he/-/he-0.5.0.tgz", - "integrity": "sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI=" + "integrity": "sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI=", + "bin": { + "he": "bin/he" + } }, - "highlight.js": { + "node_modules/highlight.js": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-7.3.0.tgz", - "integrity": "sha1-bF8PZOcHj2ZAK82/yJEQw/0bqZ8=" + "integrity": "sha1-bF8PZOcHj2ZAK82/yJEQw/0bqZ8=", + "deprecated": "Version no longer supported. Upgrade to @latest", + "engines": { + "node": "*" + } }, - "hooker": { + "node_modules/hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", - "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=" + "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", + "engines": { + "node": "*" + } }, - "htmlparser2": { + "node_modules/htmlparser2": { "version": "3.7.3", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.7.3.tgz", "integrity": "sha1-amTHdjfAjG8w7CqBV6UzM758sF4=", "dependencies": { - "domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=" - }, - "entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=" - } - } - }, - "iconv-lite": { + "domelementtype": "1", + "domhandler": "2.2", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + } + }, + "node_modules/htmlparser2/node_modules/domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dependencies": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "node_modules/htmlparser2/node_modules/entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=" + }, + "node_modules/iconv-lite": { "version": "0.2.11", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz", - "integrity": "sha1-HOYKOleGSiktEyH/RgnKS7llrcg=" + "integrity": "sha1-HOYKOleGSiktEyH/RgnKS7llrcg=", + "engines": { + "node": ">=0.4.0" + } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "isarray": { + "node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" }, - "js-yaml": { + "node_modules/js-yaml": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", - "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=" + "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=", + "dependencies": { + "argparse": "~ 0.1.11", + "esprima": "~ 1.0.2" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + }, + "engines": { + "node": ">= 0.6.0" + } }, - "lodash": { + "node_modules/lodash": { "version": "0.9.2", "resolved": "http://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz", - "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=" + "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=", + "engines": [ + "node", + "rhino" + ] }, - "lru-cache": { + "node_modules/lru-cache": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" }, - "marked": { + "node_modules/marked": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.2.tgz", - "integrity": "sha1-AV2xWIZEOPJKZL3WGgQotBhwbQk=" + "integrity": "sha1-AV2xWIZEOPJKZL3WGgQotBhwbQk=", + "bin": { + "marked": "bin/marked" + } }, - "minimatch": { + "node_modules/minimatch": { "version": "0.2.14", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=" + "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", + "deprecated": "Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue", + "dependencies": { + "lru-cache": "2", + "sigmund": "~1.0.0" + }, + "engines": { + "node": "*" + } }, - "natives": { + "node_modules/natives": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.4.tgz", - "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==" + "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==", + "deprecated": "This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x." }, - "nopt": { + "node_modules/nopt": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=" + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } }, - "readable-stream": { + "node_modules/readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=" + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } }, - "rimraf": { + "node_modules/rimraf": { "version": "2.2.8", "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=" + "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "bin": { + "rimraf": "bin.js" + } }, - "sax": { + "node_modules/sax": { "version": "0.4.3", "resolved": "http://registry.npmjs.org/sax/-/sax-0.4.3.tgz", "integrity": "sha1-cA46NOsueSzjgHkccSgPNzGWXdw=" }, - "sigmund": { + "node_modules/sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" }, - "spawnback": { + "node_modules/spawnback": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/spawnback/-/spawnback-1.0.0.tgz", "integrity": "sha1-9zZi9+VNlTZ+ynTWQmxnfdfqaG8=" }, - "string_decoder": { + "node_modules/string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, - "underscore": { + "node_modules/underscore": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" }, - "underscore.string": { + "node_modules/underscore.string": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", - "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=" + "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", + "engines": { + "node": "*" + } }, - "which": { + "node_modules/which": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", - "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=" + "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=", + "bin": { + "which": "bin/which" + } }, - "wordpress": { + "node_modules/wordpress": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordpress/-/wordpress-1.0.0.tgz", - "integrity": "sha1-m+FQ5pObYUnVw0F017UIeOK7s88=" + "integrity": "sha1-m+FQ5pObYUnVw0F017UIeOK7s88=", + "dependencies": { + "xmlrpc": "1.0.1" + }, + "engines": { + "node": "*" + } }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "xmlbuilder": { + "node_modules/xmlbuilder": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.3.1.tgz", - "integrity": "sha1-XtTCK0YiwkN/r4Pk8jbyPWu/JkE=" + "integrity": "sha1-XtTCK0YiwkN/r4Pk8jbyPWu/JkE=", + "engines": { + "node": ">=0.2.0" + } }, - "xmlrpc": { + "node_modules/xmlrpc": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/xmlrpc/-/xmlrpc-1.0.1.tgz", - "integrity": "sha1-QZcSWnn5mG1Ih2cVqC0Gj+8WiuM=" + "integrity": "sha1-QZcSWnn5mG1Ih2cVqC0Gj+8WiuM=", + "dependencies": { + "sax": "0.4.x", + "xmlbuilder": "0.3.1" + }, + "engines": { + "node": ">=0.4", + "npm": ">=1.0.0" + } } } } diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..7d1f82c --- /dev/null +++ b/reference.md @@ -0,0 +1,130 @@ +--- +layout: default +title: Reference documentation +--- + +# Goals +The ultimate goal of this plugin is to make working with forms more fun for everyone. By improving the interaction, it is easier and less annoying for the user to fill out the form and submit it. + +To achieve this, it is important that the plugin is actually deployed on websites around the world, so a lot of focus is spent on making it easy for developers - that's you - to use the plugin. + +The plugin can never replace server-side validation and doesn't intend to do so. Having both in place gives you the necessary security for your application, as well as improved usability. + +# Markup recommendations +Mandated: A 'name' attribute is required for all input elements needing validation, and the plugin will not work without this. A 'name' attribute must also be unique to the form, as this is how the plugin keeps track of all input elements. However, each group of radio or checkbox elements will share the same 'name' since the value of this grouping represents a single piece of the form data. + +Optionally: Each input can have a label associated with it, where the 'for' attribute of the label refers to the 'id' attribute of the input. It's also a common practice to have 'id' and 'name' attributes with the same value, although keep in mind that since this plugin does not use the 'id' attribute, this is not mandatory. + +```html + + +``` + +# Methods +A validation method implements the logic to validate any element. Provided are a set of default validation methods, such as `required`. Apart from `required` itself and `equalTo`, all validation methods declare an element valid when it has no value at all. That way an email field is optional unless `required` is specified. You can specify an element input to contain a valid email address, or nothing at all. Use jQuery.validator.addMethod to implement custom methods. + +# Rules +A validation rule applies one or more validation methods to an input element. You can specify validation rules via metadata or via plugin settings (option `rules`). The decision is often influenced by serverside infrastructure. If a web framework is used, it is often easier to use metadata, which is also good for fast prototyping. Plugin settings produce cleaner markup, though valid markup results from both. + +## Fields with complex names (brackets, dots) +If your form consists of fields using names that aren't legal JavaScript identifiers, you have to quote those names when using the `rules` option: + +```js + $("#myform").validate({ + rules: { + // no quoting necessary + name: "required", + // quoting necessary! + "user[email]": "email", + // dots need quoting, too! + "user.address.street": "required" + } + }); +``` + +## Refactoring rules +Whenever you have multiple fields with the same rules and messages, refactoring those can reduce a lot of duplication. Using `addMethod()` and `addClassRules()` are most effective for that. + +Let's consider an example where you have ten customer fields, each required and with a minlength of 2. You need custom messages for both rules. To avoid having to specify those rules and messages again and again, we can alias existing methods with different messages and group them into a single class: + +```js + // alias required to cRequired with new message + $.validator.addMethod("cRequired", $.validator.methods.required, + "Customer name required"); + // alias minlength, too + $.validator.addMethod("cMinlength", $.validator.methods.minlength, + // leverage parameter replacement for minlength, {0} gets replaced with 2 + $.validator.format("Customer name must have at least {0} characters")); + // combine them both, including the parameter for minlength + $.validator.addClassRules("customer", { cRequired: true, cMinlength: 2 }); +``` + +With that in place, we can add a class customer to all customer fields and be done with it: + +```html + + + +``` + +You can also reuse existing methods inside other custom methods, to reuse certain implementations. For example, if you're writing a custom method for validating email addresses inside a single field, you could call the existing `email` method for each email: + +```js +jQuery.validator.methods.email.call(this, email, element) +``` + +# Error messages +An error message displays a hint for the user about invalid elements, and what is wrong. There are four ways to provide error messages. Via the title attribute of the input element to validate, via data attributes, via error labels and via plugin settings (option `messages`). + +All validation rules included here provide a default error message which you can use for prototyping, because it is used when no specific message is provided. + +The priorities are as follows: A custom message (passed by plugin options), the element's title, the default message. + +When using data attributes, you can set a generic message for all rules, or specific messages per rule: +```html + + +``` + +# Error message display +Error messages are handled via label elements with an additional class (option `errorClass`). The link between the message and the invalid element is provided via the labels for attribute. When provided in the markup, they are shown and hidden accordingly, and otherwise created on demand. By default, labels are created after the invalid element, this is also customizable (option `errorPlacement`). It is also possible to put them into an error container (option `errorLabelContainer`). To use a different element then a label, specify the `errorElement` option. + +# General messages +In addition to field-specific messages you can display a general "your form is invalid, please fix the highlighted fields!" message in a container anywhere on your page, eg. above the form (option `errorContainer`). The container is shown and hidden when errors occur and are fixed accordingly. The container for error labels (option `errorLabelContainer`) can also be nested inside the error container. + +# Focusing of invalid elements +By default, the first invalid element in a form is focused after submitting a form with invalid elements. To prevent confusion on the behalf of the user, the plugin remembers the element that had focus when the form was submitted, and refocuses that element. That way the user can try to fill out elements of the form at the end, without being forced to focus them again and again. This can be disabled (option `focusInvalid`). + +# Form submit +By default, the form submission is prevented when the form is invalid, and submitted as normal when it is valid. You can also handle the submission manually (option `submitHandler`). + +## Skipping validation on submit +To skip validation while still using a submit-button, add the attribute "formnovalidate" to that input: + +```html + + +``` + +This used to work by adding `class="cancel"` to the input, this is now deprecated. + +[Demo for the cancel button](https://jqueryvalidation.org/files/demo/errorcontainer-demo.html) + +# Validation event +By default, forms are validated on submit, triggered by the user clicking the submit button or pressing enter when a form input is focused (option `onsubmit`). In addition, once a field was highlighted as being invalid, it is validated whenever the user types something in the field (option `onkeyup`). When the user enters something invalid into a valid field, it is also validated when the field loses focus (option `onfocusout`). + +The goal of these interactions is to provide feedback as early as possible, whilst avoiding user annoyance. Displaying error messages before the user had the chance to even type something is not helpful. + +# Developing and debugging a form +While developing and debugging the form, you should set the `debug` option to true. That prevents form submission on both valid and invalid forms and outputs some helpful messages to window.console (available via Firebug or Firebug Lite) that help debugging. When you have everything set up and don't get any error messages displayed, check if your rules all accept empty elements as valid (like email or url methods). + +Some issues are caused by certain form element's names. A name you should avoid is "submit" (for submit buttons and anything else). Browsers expose form elements as properties of the form element, by their name, in this case hiding native methods like submit(). Just don't use name="submit" and you're good. + +# Validating multiple forms on one page +The plugin can handle only one form per call. In case you have multiple forms on a single page which you want to validate, you have to initialise them all individually: +```js +$( "form" ).each( function() { + $( this ).validate( options ); +} ); +``` +You can avoid having to duplicate the plugin settings by modifying the defaults, using jQuery.validator.setDefaults to override multiple settings at once. From 093f7a5daa8b94cebaa19a3e6e53e3b81185420a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 09:57:48 +0000 Subject: [PATCH 02/22] Add Jekyll layouts and update configuration Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/56c60609-42d5-4470-b53a-8ba170e29227 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- .github/workflows/deploy-pages.yml | 6 -- Gemfile | 17 +----- README.md | 78 ++++++++++++++++-------- _config.yml | 3 +- _layouts/default.html | 96 ++++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+), 47 deletions(-) create mode 100644 _layouts/default.html diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index dd2a954..5c5d571 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -29,12 +29,6 @@ jobs: - name: Setup Pages uses: actions/configure-pages@v5 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.1' - bundler-cache: true - - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: diff --git a/Gemfile b/Gemfile index f809cbc..1f885a2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,22 +1,7 @@ source "https://rubygems.org" -gem "jekyll", "~> 4.3" -gem "minima", "~> 2.5" +gem "jekyll", "~> 3.9" group :jekyll_plugins do gem "jekyll-feed", "~> 0.12" end - -# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem -# and associated library. -platforms :mingw, :x64_mingw, :mswin, :jruby do - gem "tzinfo", ">= 1", "< 3" - gem "tzinfo-data" -end - -# Performance-booster for watching directories on Windows -gem "wdm", "~> 0.1", :platforms => [:mingw, :x64_mingw, :mswin] - -# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem -# do not have a Java counterpart. -gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] diff --git a/README.md b/README.md index 6308039..9b756c0 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,65 @@ -jqueryvalidation-content -======================== +# jQuery Validation Plugin - Content Repository -## Building +This repository contains the documentation and content for the [jQuery Validation Plugin](https://github.com/jquery-validation/jquery-validation) website. -### Requirements +## GitHub Pages Deployment -* libxml2 -* libxslt +This site is automatically deployed to GitHub Pages using Jekyll. -The `xmllint` and `xsltproc` utilities need to be in your path. If you are on Windows, you can get libxml2 and libxslt from GnuWin32. +### How it Works -* Install [WordPress](http://wordpress.org/download/) -* Install [jqueryvalidation-theme](https://github.com/jzaefferer/validation-theme) - clone that repo, then symlink it into your `wp-content/themes` folder -* Install [gilded-wordpress plugin](https://raw.githubusercontent.com/scottgonzalez/gilded-wordpress/v1.0.0/gilded-wordpress.php) -* Install [jquery-static-index plugin](https://raw.githubusercontent.com/jquery/jquery-wp-content/v4.0.1/plugins/jquery-static-index.php) +- Content is written in Markdown with Jekyll front matter +- The site is built using Jekyll (configured in `_config.yml`) +- GitHub Actions automatically builds and deploys the site when changes are pushed to the `main` or `master` branch +- The workflow is defined in `.github/workflows/deploy-pages.yml` -### Installation +### Local Development -In this repo: -* Make sure nodejs (with npm) is installed, otherwise install from nodejs.org -* `cp config-sample.json config.json`, edit config.json to match login for local WordPress -* run `npm install -g grunt-cli` -* run `npm install` +To test the site locally: -### Hacks +1. Install Ruby and Bundler: + ```bash + gem install bundler + ``` -* Make sure your local `wordpress` nodejs module contains [this commit](https://github.com/scottgonzalez/node-wordpress/commit/2b19238cf8064dafb66b9db09d0adcc9eac7f724) -* Make sure your local config contains - * rpc-auth and basic-auth credentials - * a https jqueryvalidation url +2. Install dependencies: + ```bash + bundle install + ``` -### Deploy +3. Run Jekyll locally: + ```bash + bundle exec jekyll serve + ``` -`grunt deploy` +4. Open your browser to `http://localhost:4000` + +### Making Changes + +1. Edit or create Markdown files (`.md`) in the root directory +2. Each file should have Jekyll front matter at the top: + ```yaml + --- + layout: default + title: Your Page Title + --- + ``` +3. Commit and push your changes +4. GitHub Actions will automatically build and deploy the site + +### Content Structure + +- `index.md` - Home page +- `documentation.md` - API documentation +- `contribute.md` - Contribution guide +- `reference.md` - General guidelines and reference +- `entries/` - XML documentation entries (for API methods) +- `pages/` - Original content files (kept for reference) + +### Deployment + +The site is automatically deployed via GitHub Actions when: +- Changes are pushed to `main` or `master` branch +- The workflow can also be triggered manually from the Actions tab + +No manual deployment is required! diff --git a/_config.yml b/_config.yml index 91d9780..8cea63c 100644 --- a/_config.yml +++ b/_config.yml @@ -5,7 +5,6 @@ baseurl: "" # Build settings markdown: kramdown -theme: minima # Exclude from processing exclude: @@ -22,6 +21,8 @@ exclude: - .gitignore - .gitattributes - dist + - Gemfile + - Gemfile.lock # Collections collections: diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 0000000..4227053 --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,96 @@ + + + + + + {% if page.title %}{{ page.title }} - {% endif %}{{ site.title }} + + + + +
+

{{ site.title }}

+ +
+ +
+ {% if page.title and page.url != "/" %} +

{{ page.title }}

+ {% endif %} + + {{ content }} +
+ + + + From 85582b0f163dae00bf466f610698d9dc48e6cd94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 09:58:52 +0000 Subject: [PATCH 03/22] Add setup documentation and finalize configuration Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/56c60609-42d5-4470-b53a-8ba170e29227 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- GITHUB_PAGES_SETUP.md | 54 +++++++++++++++++++++++++++++++++++++++++++ _config.yml | 5 ++-- _layouts/default.html | 10 ++++---- index.md | 4 ++-- 4 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 GITHUB_PAGES_SETUP.md diff --git a/GITHUB_PAGES_SETUP.md b/GITHUB_PAGES_SETUP.md new file mode 100644 index 0000000..94dad0b --- /dev/null +++ b/GITHUB_PAGES_SETUP.md @@ -0,0 +1,54 @@ +# GitHub Pages Setup Instructions + +This document explains how to enable GitHub Pages for this repository. + +## Automatic Deployment + +The repository is configured to automatically deploy to GitHub Pages using GitHub Actions. The workflow is defined in `.github/workflows/deploy-pages.yml`. + +## Enabling GitHub Pages + +To enable GitHub Pages for this repository, a repository administrator needs to: + +1. Go to the repository **Settings** page +2. Navigate to **Pages** in the left sidebar +3. Under **Build and deployment**: + - **Source**: Select "GitHub Actions" +4. Save the changes + +## After Enabling + +Once GitHub Pages is enabled: + +1. The workflow will automatically run when changes are pushed to `main` or `master` branch +2. You can also manually trigger the workflow from the **Actions** tab +3. The site will be available at: `https://jquery-validation.github.io/validation-content/` + - Or at your custom domain if configured + +## Testing the Deployment + +After enabling GitHub Pages and pushing changes: + +1. Go to the **Actions** tab in the repository +2. You should see the "Deploy to GitHub Pages" workflow running +3. Once complete, visit the deployed site URL +4. Verify that the content displays correctly + +## Troubleshooting + +If the deployment fails: + +1. Check the workflow logs in the **Actions** tab +2. Verify that GitHub Pages is enabled with "GitHub Actions" as the source +3. Ensure the branch being deployed (main or master) exists and has the latest changes +4. Check that all required files are present: `_config.yml`, `_layouts/default.html`, and content files + +## Custom Domain (Optional) + +To use a custom domain: + +1. Add a `CNAME` file to the repository root with your domain name +2. Configure your DNS settings to point to GitHub Pages +3. Enable HTTPS in the Pages settings (recommended) + +For more information, see: https://docs.github.com/en/pages diff --git a/_config.yml b/_config.yml index 8cea63c..fea78f2 100644 --- a/_config.yml +++ b/_config.yml @@ -1,7 +1,7 @@ title: jQuery Validation Plugin description: Site content for the jQuery Validation Plugin -url: https://jqueryvalidation.org -baseurl: "" +url: https://jquery-validation.github.io +baseurl: "/validation-content" # Build settings markdown: kramdown @@ -23,6 +23,7 @@ exclude: - dist - Gemfile - Gemfile.lock + - GITHUB_PAGES_SETUP.md # Collections collections: diff --git a/_layouts/default.html b/_layouts/default.html index 4227053..46f2ccc 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -71,12 +71,12 @@
-

{{ site.title }}

+

{{ site.title }}

diff --git a/index.md b/index.md index be9c2f1..7d0dfa7 100644 --- a/index.md +++ b/index.md @@ -20,8 +20,8 @@ Starting with Version 1.15.0 [Markus Staab](https://github.com/staabm) took over ### Files: - [Download](https://github.com/jzaefferer/jquery-validation/releases/tag/1.19.5) - zip-Archive with source code, minified and packed version, demos and examples - [Changelog](https://github.com/jzaefferer/jquery-validation/releases/tag/1.19.5) -- [Demos](//jqueryvalidation.org/files/demo/) -- [Documentation](/documentation/) +- [Demos](https://jqueryvalidation.org/files/demo/) +- [Documentation](documentation/) - [GitHub Repository](https://github.com/jzaefferer/jquery-validation) ### Installation via Package Managers From 9e0ae646fe16a131b4422c2f33428ef22f822efb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:31:33 +0000 Subject: [PATCH 04/22] Convert XML entries to Markdown format Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/3cd3a909-bae0-4790-b477-0bccbaf09aac Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- _config.yml | 4 +- _entries/Validator.destroy.md | 38 +++ _entries/Validator.element.md | 29 +++ _entries/Validator.form.md | 27 ++ _entries/Validator.numberOfInvalids.md | 32 +++ _entries/Validator.resetForm.md | 27 ++ _entries/Validator.showErrors.md | 31 +++ _entries/accept-method.md | 43 ++++ _entries/blank-selector.md | 35 +++ _entries/creditcard-method.md | 38 +++ _entries/date-method.md | 38 +++ _entries/dateISO-method.md | 38 +++ _entries/digits-method.md | 38 +++ _entries/email-method.md | 38 +++ _entries/equalTo-method.md | 46 ++++ _entries/extension-method.md | 43 ++++ _entries/filled-selector.md | 35 +++ _entries/jQuery.validator.addClassRules.md | 58 +++++ _entries/jQuery.validator.addMethod.md | 63 +++++ _entries/jQuery.validator.format.md | 36 +++ _entries/jQuery.validator.methods.md | 21 ++ _entries/jQuery.validator.setDefaults.md | 30 +++ _entries/max-method.md | 43 ++++ _entries/maxlength-method.md | 43 ++++ _entries/min-method.md | 43 ++++ _entries/minlength-method.md | 43 ++++ _entries/normalizer.md | 138 +++++++++++ _entries/number-method.md | 38 +++ _entries/phoneUS-method.md | 38 +++ _entries/range-method.md | 43 ++++ _entries/rangelength-method.md | 43 ++++ _entries/remote-method.md | 63 +++++ _entries/require_from_group-method.md | 49 ++++ _entries/required-method.md | 187 ++++++++++++++ _entries/rules.md | 83 +++++++ _entries/step-method.md | 43 ++++ _entries/unchecked-selector.md | 44 ++++ _entries/url-method.md | 38 +++ _entries/valid.md | 39 +++ _entries/validate.md | 47 ++++ convert_entries.py | 271 +++++++++++++++++++++ 41 files changed, 2123 insertions(+), 1 deletion(-) create mode 100644 _entries/Validator.destroy.md create mode 100644 _entries/Validator.element.md create mode 100644 _entries/Validator.form.md create mode 100644 _entries/Validator.numberOfInvalids.md create mode 100644 _entries/Validator.resetForm.md create mode 100644 _entries/Validator.showErrors.md create mode 100644 _entries/accept-method.md create mode 100644 _entries/blank-selector.md create mode 100644 _entries/creditcard-method.md create mode 100644 _entries/date-method.md create mode 100644 _entries/dateISO-method.md create mode 100644 _entries/digits-method.md create mode 100644 _entries/email-method.md create mode 100644 _entries/equalTo-method.md create mode 100644 _entries/extension-method.md create mode 100644 _entries/filled-selector.md create mode 100644 _entries/jQuery.validator.addClassRules.md create mode 100644 _entries/jQuery.validator.addMethod.md create mode 100644 _entries/jQuery.validator.format.md create mode 100644 _entries/jQuery.validator.methods.md create mode 100644 _entries/jQuery.validator.setDefaults.md create mode 100644 _entries/max-method.md create mode 100644 _entries/maxlength-method.md create mode 100644 _entries/min-method.md create mode 100644 _entries/minlength-method.md create mode 100644 _entries/normalizer.md create mode 100644 _entries/number-method.md create mode 100644 _entries/phoneUS-method.md create mode 100644 _entries/range-method.md create mode 100644 _entries/rangelength-method.md create mode 100644 _entries/remote-method.md create mode 100644 _entries/require_from_group-method.md create mode 100644 _entries/required-method.md create mode 100644 _entries/rules.md create mode 100644 _entries/step-method.md create mode 100644 _entries/unchecked-selector.md create mode 100644 _entries/url-method.md create mode 100644 _entries/valid.md create mode 100644 _entries/validate.md create mode 100644 convert_entries.py diff --git a/_config.yml b/_config.yml index fea78f2..e084902 100644 --- a/_config.yml +++ b/_config.yml @@ -24,12 +24,14 @@ exclude: - Gemfile - Gemfile.lock - GITHUB_PAGES_SETUP.md + - entries + - convert_entries.py # Collections collections: entries: output: true - permalink: /:collection/:name/ + permalink: /:name/ defaults: - scope: diff --git a/_entries/Validator.destroy.md b/_entries/Validator.destroy.md new file mode 100644 index 0000000..12561b5 --- /dev/null +++ b/_entries/Validator.destroy.md @@ -0,0 +1,38 @@ +--- +title: Validator.destroy() +entry_name: Validator.destroy +entry_type: method +category: validator +layout: default +--- + +# Validator.destroy() + +Destroys this instance of validator freeing up resources and unregistering events. + +## Description + +This is only useful, when you need to clean up after the validator in a Single Page Application. + +## Usage + + +## Examples + +Destroying an instance of validator. + +```javascript +/* + * On SPA page start. + */ +var validator = $( "#myform" ).validate(); + +/* + * Just before SPA page's navigation away. + */ +validator.destroy(); + +/* + * After this point the #myForm form is back to its original boring state. + */ +``` diff --git a/_entries/Validator.element.md b/_entries/Validator.element.md new file mode 100644 index 0000000..43db960 --- /dev/null +++ b/_entries/Validator.element.md @@ -0,0 +1,29 @@ +--- +title: Validator.element() +entry_name: Validator.element +entry_type: method +category: validator +layout: default +--- + +# Validator.element() + +Validates a single element, returns true if it is valid, false otherwise. + +## Description + +This behaves as validation on blur or keyup, but returns the result. + +## Usage + +**element** *(Selector)* +: An element to validate, must be inside the validated form. + +## Examples + +Triggers element validation programmatically. + +```javascript +var validator = $( "#myform" ).validate(); +validator.element( "#myselect" ); +``` diff --git a/_entries/Validator.form.md b/_entries/Validator.form.md new file mode 100644 index 0000000..491dd02 --- /dev/null +++ b/_entries/Validator.form.md @@ -0,0 +1,27 @@ +--- +title: Validator.form() +entry_name: Validator.form +entry_type: method +category: validator +layout: default +--- + +# Validator.form() + +Validates the form, returns true if it is valid, false otherwise. + +## Description + +This behaves as a normal submit event, but returns the result. + +## Usage + + +## Examples + +Triggers form validation programmatically. + +```javascript +var validator = $( "#myform" ).validate(); +validator.form(); +``` diff --git a/_entries/Validator.numberOfInvalids.md b/_entries/Validator.numberOfInvalids.md new file mode 100644 index 0000000..816f603 --- /dev/null +++ b/_entries/Validator.numberOfInvalids.md @@ -0,0 +1,32 @@ +--- +title: Validator.numberOfInvalids() +entry_name: Validator.numberOfInvalids +entry_type: method +category: validator +layout: default +--- + +# Validator.numberOfInvalids() + +Returns the number of invalid fields. + +## Description + +This depends on the internal validator state. It covers all fields only after validating the complete form (on submit or via $("form").valid()). After validating a single element, only that element is counted. Most useful in combination with the invalidHandler-option. + +## Usage + +**errors** *(Object)* +: One or more key/value pairs of input names and messages. + +## Examples + +Displays a summary of invalid fields after an invalid submit. + +```javascript +var validator = $( "#myform" ).validate({ + invalidHandler: function() { + $( "#summary" ).text( validator.numberOfInvalids() + " field(s) are invalid" ); + } +}); +``` diff --git a/_entries/Validator.resetForm.md b/_entries/Validator.resetForm.md new file mode 100644 index 0000000..18539a7 --- /dev/null +++ b/_entries/Validator.resetForm.md @@ -0,0 +1,27 @@ +--- +title: Validator.resetForm() +entry_name: Validator.resetForm +entry_type: method +category: validator +layout: default +--- + +# Validator.resetForm() + +Resets the controlled form. + +## Description + +Resets input fields to their original value (requires form plugin), removes classes indicating invalid elements and hides error messages. + +## Usage + + +## Examples + +Reset the form controlled by this validator. + +```javascript +var validator = $( "#myform" ).validate(); +validator.resetForm(); +``` diff --git a/_entries/Validator.showErrors.md b/_entries/Validator.showErrors.md new file mode 100644 index 0000000..48df127 --- /dev/null +++ b/_entries/Validator.showErrors.md @@ -0,0 +1,31 @@ +--- +title: Validator.showErrors() +entry_name: Validator.showErrors +entry_type: method +category: validator +layout: default +--- + +# Validator.showErrors() + +Show the specified messages. + +## Description + +Keys have to refer to the names of elements, values are displayed for those elements, using the configured error placement. + +## Usage + +**errors** *(Object)* +: One or more key/value pairs of input names and messages. + +## Examples + +Adds and shows error message programmatically. + +```javascript +var validator = $( "#myshowErrors" ).validate(); +validator.showErrors({ + "firstname": "I know that your firstname is Pete, Pete!" +}); +``` diff --git a/_entries/accept-method.md b/_entries/accept-method.md new file mode 100644 index 0000000..b0543a3 --- /dev/null +++ b/_entries/accept-method.md @@ -0,0 +1,43 @@ +--- +title: accept method +entry_name: accept +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# accept method + +Makes a file upload accept only specified mime-types. + +## Description + +Uses the HTML5 file API to look at the type attribute of one or more selected files and validate that each matches the specified mime-type. If nothing is specified, only images are allowed (image/*). You can specify multiple mime-types by separating them with a comma, e.g. "image/x-eps,application/pdf". Works with type="file" inputs. Part of the additional-methods.js file Note: This method used to look at just the filename, specifically the file extension. That behaviour is now available as the "extension" method inside src/additional/extension.js. + +## Usage + +**mimetype** *(String)* +: The allowed type, seperated via ",", defaults to "image/*" + +## Examples + +Required, only audio files allowed: + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + accept: "audio/*" + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/blank-selector.md b/_entries/blank-selector.md new file mode 100644 index 0000000..48c5d2c --- /dev/null +++ b/_entries/blank-selector.md @@ -0,0 +1,35 @@ +--- +title: :blank Selector +entry_name: blank +entry_type: selector +category: selectors +layout: default +--- + +# :blank Selector + +**Selector:** `:blank` + +Selects all elements with a blank value. + +## Description + +Blank means either no value at all or only whitespace. The implementation does a check like this: `jQuery.trim(value).length == 0` + +## Usage + + +## Examples + +Finds input elements with no value or just whitespace. + +```javascript +$( "input:blank" ).css( "background-color", "#bbbbff" ); +``` + +```html +
Mouseover to see the value of each input
+ + + +``` diff --git a/_entries/creditcard-method.md b/_entries/creditcard-method.md new file mode 100644 index 0000000..444cd64 --- /dev/null +++ b/_entries/creditcard-method.md @@ -0,0 +1,38 @@ +--- +title: creditcard method +entry_name: creditcard +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# creditcard method + +Makes the element require a credit card number. + +## Description + +Return true if the value is a valid credit card number. Works with text inputs. Part of the additional-methods.js file Note: The algorithm used can't verify the validity of the number - it is just an integrity check. As with any other clientside validation, you have to implement the same or better validation on the serverside. + +## Examples + +Makes "field" required and credit card only. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + creditcard: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/date-method.md b/_entries/date-method.md new file mode 100644 index 0000000..8b4a2b3 --- /dev/null +++ b/_entries/date-method.md @@ -0,0 +1,38 @@ +--- +title: [DEPRECATED] date method +entry_name: date +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# [DEPRECATED] date method + +Makes the element require a date. + +## Description + +Return true if the value is a valid date. Uses JavaScript's built-in Date to test if the date is valid, and therefore does no sanity checks. Only the format must be valid, not the actual date, eg 30/30/2008 is a valid date. DEPRECATION warning: This method is deprecated and will be removed in version 2.0.0.Please don't use it, since it relies on the Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js). + +## Examples + +Makes "field" required and a date. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + date: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/dateISO-method.md b/_entries/dateISO-method.md new file mode 100644 index 0000000..8486568 --- /dev/null +++ b/_entries/dateISO-method.md @@ -0,0 +1,38 @@ +--- +title: dateISO method +entry_name: dateISO +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# dateISO method + +Makes the element require an ISO date. + +## Description + +Return true if the value is a valid date according to ISO date standard. Works with text inputs. + +## Examples + +Makes "field" required and an ISO date. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + dateISO: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/digits-method.md b/_entries/digits-method.md new file mode 100644 index 0000000..9182bc0 --- /dev/null +++ b/_entries/digits-method.md @@ -0,0 +1,38 @@ +--- +title: digits method +entry_name: digits +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# digits method + +Makes the element require digits only. + +## Description + +Returns true if the value contains only digits. Works with text inputs. + +## Examples + +Makes "field" required and digits only. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + digits: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/email-method.md b/_entries/email-method.md new file mode 100644 index 0000000..5e9d360 --- /dev/null +++ b/_entries/email-method.md @@ -0,0 +1,38 @@ +--- +title: email method +entry_name: email +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# email method + +Makes the element require a valid email + +## Description + +Return true if the value is a valid email address. Works with text inputs. IMPORTANT NOTE: As of version 1.12.0 we started using the same regular expression that the HTML5 specification suggests for browsers to use. We will follow their lead and use the same check. In case you need to adjust the built-in validation regular expression patterns, please use the $.validator.methods property. If you have different requirements, please consider using a custom method. + +## Examples + +Makes "field" required and an email address. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + email: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/equalTo-method.md b/_entries/equalTo-method.md new file mode 100644 index 0000000..8eaac9f --- /dev/null +++ b/_entries/equalTo-method.md @@ -0,0 +1,46 @@ +--- +title: equalTo method +entry_name: equalTo +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# equalTo method + +Requires the element to be the same as another one + +## Description + +Returns true if the value has the same value as the element specified by the first parameter. + +## Usage + +**other** *(Selector)* +: The selector for the element to compare the current values + +## Examples + +Makes "field" required to be the same as #other + +```javascript +$( "#myform" ).validate({ + rules: { + password: "required", + password_again: { + equalTo: "#password" + } + } +}); +``` + +```html + + +
+ + +
+ +``` diff --git a/_entries/extension-method.md b/_entries/extension-method.md new file mode 100644 index 0000000..80b6389 --- /dev/null +++ b/_entries/extension-method.md @@ -0,0 +1,43 @@ +--- +title: extension method +entry_name: extension +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# extension method + +Makes the element require a certain file extension. + +## Description + +Returns true if the value ends with one of the specified file extensions. If nothing is specified, only images are allowed (png, jpeg, gif). Works with text inputs. Part of the additional-methods.js file + +## Usage + +**extension** *(String)* (optional) +: The allowed file extensions, seperated with "|" (or a comma, ","), defaults to "png|jpe?g|gif". + +## Examples + +Makes "field" required and ending with ".xls" or ".csv". + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + extension: "xls|csv" + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/filled-selector.md b/_entries/filled-selector.md new file mode 100644 index 0000000..9e35f3b --- /dev/null +++ b/_entries/filled-selector.md @@ -0,0 +1,35 @@ +--- +title: :filled Selector +entry_name: filled +entry_type: selector +category: selectors +layout: default +--- + +# :filled Selector + +**Selector:** `:filled` + +Selects all elements with a filled value. + +## Description + +filled means any value, but not only whitespace. The implementation does a check like this: `jQuery.trim(value).length > 0` + +## Usage + + +## Examples + +Finds input elements with a non-whitespace value. + +```javascript +$( "input:filled" ).css( "background-color", "#bbbbff" ); +``` + +```html +
Mouseover to see the value of each input
+ + + +``` diff --git a/_entries/jQuery.validator.addClassRules.md b/_entries/jQuery.validator.addClassRules.md new file mode 100644 index 0000000..b055f53 --- /dev/null +++ b/_entries/jQuery.validator.addClassRules.md @@ -0,0 +1,58 @@ +--- +title: jQuery.validator.addClassRules() +entry_name: jQuery.validator.addClassRules +entry_type: method +category: validator +layout: default +--- + +# jQuery.validator.addClassRules() + +Add a compound class method - useful to refactor common combinations of rules into a single class. + +## Usage + +### Form 1 + +**name** *(String)* +: The name of the class rule to add + +**rules** *(Object)* +: The compound rules (see example) + +### Form 2 + +**rules** *(Object)* +: A map of className-rules pairs (see example). + +## Examples + +### Example 1 + +Add a new compound rule called "name", replacing class="required" minlength="2" with class="name". + +```javascript +jQuery.validator.addClassRules("name", { + required: true, + minlength: 2 +}); +``` + +### Example 2 + +Add two compound class rules for name and zip. + +```javascript +jQuery.validator.addClassRules({ + name: { + required: true, + minlength: 2 + }, + zip: { + required: true, + digits: true, + minlength: 5, + maxlength: 5 + } +}); +``` diff --git a/_entries/jQuery.validator.addMethod.md b/_entries/jQuery.validator.addMethod.md new file mode 100644 index 0000000..3930581 --- /dev/null +++ b/_entries/jQuery.validator.addMethod.md @@ -0,0 +1,63 @@ +--- +title: jQuery.validator.addMethod() +entry_name: jQuery.validator.addMethod +entry_type: method +category: validator +layout: default +--- + +# jQuery.validator.addMethod() + +Add a custom validation method. It must consist of a name (must be a legal javascript identifier), a javascript based function and a default string message. + +## Description + +For simple one-off validation, you can use the bundled `pattern` method (in additional methods, source in `src/additional/pattern.js`) to validate a field against a regular expression. In general, it is a good idea to encapsulate those regular expressions inside their own method. If you need lots of slightly different expressions, try to extract a common parameter. See also a [library of regular expressions](http://regexlib.com/DisplayPatterns.aspx). + +## Usage + +**name** *(String)* +: The name of the method used to identify it and referencing it; this must be a valid JavaScript identifier + +**method** *(Function)* +: The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters. + + - **value** *(String)*: the current value of the validated element + - **element** *(Element)*: the element to be validated + - **params** *(Object)*: parameters specified for the method, e.g. for min: 5, the parameter is 5, for range: [1, 5] it's [1, 5] + +**message** *(String)* (optional) +: The default message to display for this method. Can be a function created by ''jQuery.validator.format(value)''. When undefined, an existing message is used (handy for localization), otherwise the field-specific messages have to be defined. + +## Examples + +### Example 1 + +Add a validation method that checks if a value starts with a certain domain. + +```javascript +jQuery.validator.addMethod("domain", function(value, element) { + return this.optional(element) || /^http:\/\/mycorporatedomain.com/.test(value); +}, "Please specify the correct domain for your documents"); +``` + +### Example 2 + +Adds a validation method that checks if a given value equals the addition of the two parameters. + +```javascript +jQuery.validator.addMethod("math", function(value, element, params) { + return this.optional(element) || value == params[0] + params[1]; +}, jQuery.validator.format("Please enter the correct value for {0} + {1}")); +``` + +### Example 3 + +Adds a custom email validation method that is less strict than the one built-in. + +```javascript +jQuery.validator.addMethod("laxEmail", function(value, element) { + // allow any non-whitespace characters as the host part + return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:\S{1,63})$/.test( value ); +}, 'Please enter a valid email address.'); +``` diff --git a/_entries/jQuery.validator.format.md b/_entries/jQuery.validator.format.md new file mode 100644 index 0000000..e8dc97c --- /dev/null +++ b/_entries/jQuery.validator.format.md @@ -0,0 +1,36 @@ +--- +title: jQuery.validator.format() +entry_name: jQuery.validator.format +entry_type: method +category: validator +layout: default +--- + +# jQuery.validator.format() + +Replaces {n} placeholders with arguments. + +## Description + +One or more arguments can be passed, in addition to the string template itself, to insert into the string. If you're familiar with the term, this makes this function support currying. If you don't care about that, just use the first argument. + +## Usage + +**template** *(String)* +: The string to format. + +**argument** *(Object)* +: The first argument to insert, or an array of Strings to insert + +**argumentN...** *(Object)* +: The second etc. argument to insert + +## Examples + +Sets the debug setting for all validation calls. + +```javascript +var template = jQuery.validator.format("{0} is not a valid value"); +// later, results in 'abc is not a valid value' +alert(template("abc")); +``` diff --git a/_entries/jQuery.validator.methods.md b/_entries/jQuery.validator.methods.md new file mode 100644 index 0000000..3b2be3f --- /dev/null +++ b/_entries/jQuery.validator.methods.md @@ -0,0 +1,21 @@ +--- +title: jQuery.validator.methods +entry_name: jQuery.validator.methods +entry_type: method +category: validator +layout: default +--- + +# jQuery.validator.methods + +Object holding all validation methods known to the validator. This can be accessed to override individual methods, while keeping the default messages. + +## Examples + +Sets a custom email pattern for the built-in email validation rule. + +```javascript +$.validator.methods.email = function( value, element ) { + return this.optional( element ) || /[a-z]+@[a-z]+\.[a-z]+/.test( value ); +} +``` diff --git a/_entries/jQuery.validator.setDefaults.md b/_entries/jQuery.validator.setDefaults.md new file mode 100644 index 0000000..2f820c8 --- /dev/null +++ b/_entries/jQuery.validator.setDefaults.md @@ -0,0 +1,30 @@ +--- +title: jQuery.validator.setDefaults() +entry_name: jQuery.validator.setDefaults +entry_type: method +category: validator +layout: default +--- + +# jQuery.validator.setDefaults() + +Modify default settings for validation. + +## Description + +Accepts everything that [validate()](/validate) accepts. + +## Usage + +**options** *(Object)* +: Options to set as default. + +## Examples + +Sets the debug setting for all validation calls. + +```javascript +jQuery.validator.setDefaults({ + debug: true +}); +``` diff --git a/_entries/max-method.md b/_entries/max-method.md new file mode 100644 index 0000000..f03340a --- /dev/null +++ b/_entries/max-method.md @@ -0,0 +1,43 @@ +--- +title: max method +entry_name: max +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# max method + +Makes the element require a given maximum. + +## Description + +Works with text inputs. To exclude the maximum value, subtract Number.MIN_VALUE from that value. + +## Usage + +**value** *(Number)* +: Maximum value required + +## Examples + +Makes "field" required and 23 or smaller. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + max: 23 + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/maxlength-method.md b/_entries/maxlength-method.md new file mode 100644 index 0000000..d4f4573 --- /dev/null +++ b/_entries/maxlength-method.md @@ -0,0 +1,43 @@ +--- +title: maxlength method +entry_name: maxlength +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# maxlength method + +Makes the element require a given maximum length. + +## Description + +Return false if the element is some kind of text input and its value is too long a set of checkboxes that has too many boxes checked a select and has too many options selected Works with text inputs, selects and checkboxes. + +## Usage + +**length** *(Number)* +: Maximum number of characters required + +## Examples + +Makes "field" required having at most 4 characters. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + maxlength: 4 + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/min-method.md b/_entries/min-method.md new file mode 100644 index 0000000..3023c55 --- /dev/null +++ b/_entries/min-method.md @@ -0,0 +1,43 @@ +--- +title: min method +entry_name: min +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# min method + +Makes the element require a given minimum. + +## Description + +Works with text inputs. To exclude the minimum value, add Number.MIN_VALUE to that value. + +## Usage + +**value** *(Number)* +: Minimum value required + +## Examples + +Makes "field" required and 13 or larger. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + min: 13 + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/minlength-method.md b/_entries/minlength-method.md new file mode 100644 index 0000000..0110371 --- /dev/null +++ b/_entries/minlength-method.md @@ -0,0 +1,43 @@ +--- +title: minlength method +entry_name: minlength +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# minlength method + +Makes the element require a given minimum length. + +## Description + +Return false if the element is some kind of text input and its value is too short a set of checkboxes that doesn't have enough boxes checked a select and doesn't have enough options selected Works with text inputs, selects and checkboxes. + +## Usage + +**length** *(Number)* +: Minimum number of characters required + +## Examples + +Makes "field" required having at least 3 characters. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + minlength: 3 + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/normalizer.md b/_entries/normalizer.md new file mode 100644 index 0000000..f441b63 --- /dev/null +++ b/_entries/normalizer.md @@ -0,0 +1,138 @@ +--- +title: normalizer +entry_name: normalizer +entry_type: method +return_type: String +category: methods +layout: default +--- + +# normalizer + +Prepares/transforms the elements value for validation. + +## Description + +Transform the value of an element and the result for validation instead of the initial value. The normalizer can be defined global to all elements or local to only one element. With that said, the local normalizer will only run for the element for which it was defined. The global normalizer will run for all validated elements. This normalizer can be then overrided for each element, as needed, by attaching one to it. This way only the local one will run for that element, and the global one will run for others. Note that this method: Has been available since version 1.15.0 Doesn't change the elements' value, it only changes the value used for validation. Gets the value passed as argument, and "this" within it references the corresponding DOMElement. For versions between 1.15.0 and 1.17.0, it must return a string value. And as of 1.17.1, it can return any value including null and undefined. + +## Usage + +**value** *(String)* +: The value of the element. + +## Examples + +### Example 1 + +Makes "field" required and use a normalizer to trim its value before validating + +```javascript +$( "#myform" ).validate( { + rules: { + field: { + required: true, + normalizer: function( value ) { + // Trim the value of the `field` element before + // validating. this trims only the value passed + // to the attached validators, not the value of + // the element itself. + return $.trim( value ); + } + } + } +} ); +``` + +```html + + +
+ +``` + +### Example 2 + +Makes "url" required and use a normalizer to append 'http://', if not present, to the value of the "url" element before validating + +```javascript +$( "#myform" ).validate( { + rules: { + url_input: { + required: true, + url: true, + normalizer: function( value ) { + var url = value; + + // Check if it doesn't start with http:// or https:// or ftp:// + if ( url && url.substr( 0, 7 ) !== "http://" + && url.substr( 0, 8 ) !== "https://" + && url.substr( 0, 6 ) !== "ftp://" ) { + // then prefix with http:// + url = "http://" + url; + } + + // Return the new url + return url; + } + } + } +} ); +``` + +```html + + +
+ +``` + +### Example 3 + +Using a global normalizer in conjunction with a local one + +```javascript +$( "#myform" ).validate( { + // This global normalizer will trim the value of all elements + // before validatng them. + normalizer: function( value ) { + return $.trim( value ); + }, + rules: { + username: { + required: true + }, + url_input: { + required: true, + url: true, + + // We don't need to trim the value of this element, so we overrided + // the global normalizer in order to append 'http://' to the url value + // if doesn't already. + normalizer: function( value ) { + var url = value; + + // Check if it doesn't start with http:// or https:// or ftp:// + if ( url && url.substr( 0, 7 ) !== "http://" + && url.substr( 0, 8 ) !== "https://" + && url.substr( 0, 6 ) !== "ftp://" ) { + // then prefix with http:// + url = "http://" + url; + } + + // Return the new url + return url; + } + } + } +} ); +``` + +```html + + +
+ + +
+ +``` diff --git a/_entries/number-method.md b/_entries/number-method.md new file mode 100644 index 0000000..db36c62 --- /dev/null +++ b/_entries/number-method.md @@ -0,0 +1,38 @@ +--- +title: number method +entry_name: number +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# number method + +Makes the element require a decimal number. + +## Description + +Returns true if the value contains a valid decimal number. Works with text inputs. + +## Examples + +Makes "field" required and a decimal number only. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + number: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/phoneUS-method.md b/_entries/phoneUS-method.md new file mode 100644 index 0000000..e7770c7 --- /dev/null +++ b/_entries/phoneUS-method.md @@ -0,0 +1,38 @@ +--- +title: phoneUS method +entry_name: phoneUS +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# phoneUS method + +Validate for valid US phone number. + +## Description + +Works with text inputs. Part of the additional-methods.js file + +## Examples + +Makes "field" required and a US phone number. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + phoneUS: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/range-method.md b/_entries/range-method.md new file mode 100644 index 0000000..506804a --- /dev/null +++ b/_entries/range-method.md @@ -0,0 +1,43 @@ +--- +title: range method +entry_name: range +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# range method + +Makes the element require a given value range. + +## Description + +Works with text inputs. To exclude the maximum value, subtract Number.MIN_VALUE from that value. To exclude the minimum value, add Number.MIN_VALUE to that value. + +## Usage + +**range** *(Array)* +: Value range required + +## Examples + +Makes "field" required and between 13 and 23. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + range: [13, 23] + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/rangelength-method.md b/_entries/rangelength-method.md new file mode 100644 index 0000000..dabcff5 --- /dev/null +++ b/_entries/rangelength-method.md @@ -0,0 +1,43 @@ +--- +title: rangelength method +entry_name: rangelength +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# rangelength method + +Makes the element require a given value range. + +## Description + +Return false if the element is some kind of text input and its length is too short or too long a set of checkboxes that doesn't have enough, or has too many boxes checked a select that doesn't have enough, or has too many options selected Works with text inputs, selects and checkboxes. + +## Usage + +**range** *(Array)* +: Value range required + +## Examples + +Makes "field" required and between 2 and 6 characters long. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + rangelength: [2, 6] + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/remote-method.md b/_entries/remote-method.md new file mode 100644 index 0000000..f4ef22d --- /dev/null +++ b/_entries/remote-method.md @@ -0,0 +1,63 @@ +--- +title: remote method +entry_name: remote +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# remote method + +Requests a resource to check the element for validity. + +## Description + +The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a key/value pair corresponding to the name of the validated element and its value as a GET parameter. The serverside response must be a JSON string that must be `"true"` for valid elements, and can be `"false"`, `undefined`, or `null` for invalid elements, using the default error message. If the serverside response is a string, eg. `"That name is already taken, try peter123 instead"`, this string will be displayed as a custom error message in place of the default. For more examples, take a look the [marketo demo](//jqueryvalidation.org/files/demo/marketo) and the [milk demo](//jqueryvalidation.org/files/demo/milk/). + +## Usage + +**options** *(Object)* +: For the URL of the resource to request for serverside validation (String) or options to fully customize the request, see [jQuery.ajax](https://api.jquery.com/jQuery.ajax) for details. These options deep-extend the defaults (`dataType:"json", data:{nameOfTheElement:valueOfTheElement}`). Any options you provide will override the defaults. + +## Examples + +### Example 1 + +Makes the email field required, an email and does a remote request to check if the given address is already taken. + +```javascript +$( "#myform" ).validate({ + rules: { + email: { + required: true, + email: true, + remote: "check-email.php" + } + } +}); +``` + +### Example 2 + +Makes the email field required, an email and does a remote request to check if the given address is already taken. In addition, the http method is set to "post" and the username is sent alongside the email address. + +```javascript +$( "#myform" ).validate({ + rules: { + email: { + required: true, + email: true, + remote: { + url: "check-email.php", + type: "post", + data: { + username: function() { + return $( "#username" ).val(); + } + } + } + } + } +}); +``` diff --git a/_entries/require_from_group-method.md b/_entries/require_from_group-method.md new file mode 100644 index 0000000..a5c6016 --- /dev/null +++ b/_entries/require_from_group-method.md @@ -0,0 +1,49 @@ +--- +title: require_from_group method +entry_name: require_from_group +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# require_from_group method + +Ensures a given number of fields in a group are complete. + +## Description + +In the options passed to the rule, supply the minimum number of fields within the group that must be complete and a selector to define the group. Then apply this rule to all the fields within the group. The form then cannot be submitted until at least the minimum number have been completed. Part of the additional-methods.js file + +## Examples + +Within a group of three phone numbers, ensure at least one is complete. + +```javascript +$( "#myform" ).validate({ + rules: { + mobile_phone: { + require_from_group: [1, ".phone-group"] + }, + home_phone: { + require_from_group: [1, ".phone-group"] + }, + work_phone: { + require_from_group: [1, ".phone-group"] + } + } +}); +``` + +```html + + +
+ + +
+ + +
+ +``` diff --git a/_entries/required-method.md b/_entries/required-method.md new file mode 100644 index 0000000..ee709d8 --- /dev/null +++ b/_entries/required-method.md @@ -0,0 +1,187 @@ +--- +title: required method +entry_name: required +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# required method + +Makes the element required. + +## Description + +Return false, if the element is empty (text input) or unchecked (radio/checkbox) or if nothing is selected (select). Works with text inputs, selects, checkboxes and radio buttons. To force a user to select an option from a select box, provide an empty option element like Note that white spaces are considered valid. + +## Usage + +### Form 1 + +The element is always required. + +### Form 2 + +Makes the element required, depending on the result of the given expression. + +**dependency-expression** *(String)* +: An expression (String) that is evaluated in the context of the element's form, making the field required only if the expression returns more than one element. Very often your expression will use selector filters such as `#foo:checked`, `#foo:filled`, `#foo:visible`. This plugin provides [custom selectors for that purpose](/category/selectors/). + +### Form 3 + +Makes the element required, depending on the result of the given callback. + +**dependency-callback** *(Function)* +: The function is executed with the element as it's only argument: If it returns true, the element is required. + +## Examples + +### Example 1 + +Makes "field" always required. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true + } + } +}); +``` + +```html + + +
+ +``` + +### Example 2 + +Makes the fruit select required. + +```javascript +$( "#myform" ).validate({ + rules: { + fruit: { + required: true + } + } +}); +``` + +```html + + +
+ +``` + +### Example 3 + +Makes the gender radio buttons required. + +```javascript +$( "#myform" ).validate({ + rules: { + gender: { + required: true + } + } +}); +``` + +```html + + + +
+ +``` + +### Example 4 + +Makes the agree checkbox required. + +```javascript +$( "#myform" ).validate({ + rules: { + agree: { + required: true + } + } +}); +``` + +```html + + +
+ +``` + +### Example 5 + +Makes details required only if #other is checked. + +```javascript +$( "#myform" ).validate({ + rules: { + details: { + required: "#other:checked" + } + } +}); +``` + +```html + + +
+ +
+ +``` + +### Example 6 + +Makes "parent" required only if age is below 13. + +```javascript +$( "#myform" ).validate({ + rules: { + age: { + required: true, + min: 3 + }, + parent: { + required: function(element) { + return $("#age").val() < 13; + } + } + } +}); +``` + +```html + + +
+ + +
+ +``` diff --git a/_entries/rules.md b/_entries/rules.md new file mode 100644 index 0000000..99b905e --- /dev/null +++ b/_entries/rules.md @@ -0,0 +1,83 @@ +--- +title: .rules() +entry_name: rules +entry_type: method +return_type: Object +category: plugin +layout: default +--- + +# .rules() + +Read, add and remove rules for an element. + +## Description + +Returns the validations rules for the first selected element or Adds the specified rules and returns all rules for the first matched element. Requires that the parent form is validated, that is, $( "form" ).validate() is called first or Removes the specified rules and returns all rules for the first matched element. There are several ways to specify validation rules. Validation methods with parameters can be specified as attributes (recommended) Validation methods without parameters can be specified as classes on the element Both can be specified using the rules-option of the validate()-method Both rules and messages can be specified using data attributes, using data-msg (a generic, not-method specific message), data-msg-[method] and data-rule-[method]. When setting, the rules can also contain a messages-object, specifying custom messages for existing or added rules. + +## Usage + +### Form 1 + +Read rules for the first element + +### Form 2 + +Add rules + +**"add"** *(String)* + +**rules** *(Object)* +: The rules to add. Accepts the same format as the rules-option of the validate-method. + +### Form 3 + +Remove rules + +**"remove"** *(String)* + +**rules** *(Object)* +: The space-seperated names of rules to remove and return. If left unspecified, removes and returns all rules. Manipulates only rules specified via rules-option or via rules("add"). + +## Examples + +### Example 1 + +Adds minlength: 2 to an element which is already required. + +```javascript +$( "#myinput" ).rules( "add", { + minlength: 2 +}); +``` + +### Example 2 + +Adds required and minlength: 2 to an element and specifies custom messages for both. + +```javascript +$( "#myinput" ).rules( "add", { + required: true, + minlength: 2, + messages: { + required: "Required input", + minlength: jQuery.validator.format("Please, at least {0} characters are necessary") + } +}); +``` + +### Example 3 + +Removes all static rules from an element. + +```javascript +$( "#myinput" ).rules( "remove" ); +``` + +### Example 4 + +Removes min and max rules from an element. + +```javascript +$( "#myinput" ).rules( "remove", "min max" ); +``` diff --git a/_entries/step-method.md b/_entries/step-method.md new file mode 100644 index 0000000..d770d9a --- /dev/null +++ b/_entries/step-method.md @@ -0,0 +1,43 @@ +--- +title: step method +entry_name: step +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# step method + +Makes the element require a given step. + +## Description + +Works with text inputs. No support for input types: date, datetime, datetime-local, month, time and week. + +## Usage + +**value** *(Number)* +: Step value required + +## Examples + +Makes "field" required and step of 10. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + step: 10 + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/unchecked-selector.md b/_entries/unchecked-selector.md new file mode 100644 index 0000000..451edda --- /dev/null +++ b/_entries/unchecked-selector.md @@ -0,0 +1,44 @@ +--- +title: :unchecked Selector +entry_name: unchecked +entry_type: selector +category: selectors +layout: default +--- + +# :unchecked Selector + +**Selector:** `:unchecked` + +Selects all elements that are unchecked. + +## Description + +Inversion of [:checked](https://api.jquery.com/checked). + +## Usage + + +## Examples + +Finds all input elements that are unchecked. + +```javascript +function countUnchecked() { + var n = $( "input:unchecked" ).length; + $( "div" ).text(n + (n == 1 ? " is" : " are") + " unchecked!" ); +} +countUnchecked(); +$( ":checkbox" ).click( countUnchecked ); +``` + +```html +
+ + + + + +
+
+``` diff --git a/_entries/url-method.md b/_entries/url-method.md new file mode 100644 index 0000000..42b6609 --- /dev/null +++ b/_entries/url-method.md @@ -0,0 +1,38 @@ +--- +title: url method +entry_name: url +entry_type: method +return_type: Boolean +category: methods +layout: default +--- + +# url method + +Makes the element require a valid url + +## Description + +Return true, if the value is a valid url. Works with text inputs. + +## Examples + +Makes "field" required and a url. + +```javascript +$( "#myform" ).validate({ + rules: { + field: { + required: true, + url: true + } + } +}); +``` + +```html + + +
+ +``` diff --git a/_entries/valid.md b/_entries/valid.md new file mode 100644 index 0000000..1ab56be --- /dev/null +++ b/_entries/valid.md @@ -0,0 +1,39 @@ +--- +title: .valid() +entry_name: valid +entry_type: method +return_type: Boolean +category: plugin +layout: default +--- + +# .valid() + +Checks whether the selected form is valid or whether all selected elements are valid. + +## Description + +[validate()](/validate) needs to be called on the form before checking it using this method. + +## Usage + + +## Examples + +Sets up validation for a form, then checks if the form is valid when clicking a button. + +```javascript +var form = $( "#myform" ); +form.validate(); +$( "button" ).click(function() { + alert( "Valid: " + form.valid() ); +}); +``` + +```html +
+ +
+ +
+``` diff --git a/_entries/validate.md b/_entries/validate.md new file mode 100644 index 0000000..acf97c0 --- /dev/null +++ b/_entries/validate.md @@ -0,0 +1,47 @@ +--- +title: .validate() +entry_name: validate +entry_type: method +return_type: Validator +category: plugin +layout: default +--- + +# .validate() + +Validates the selected form. + +## Description + +This method sets up event handlers for submit, focus, keyup, blur and click to trigger validation of the entire form or individual elements. Each one can be disabled, see the onxxx options (onsubmit, onfocusout, onkeyup, onclick). focusInvalid focuses elements when submitting an invalid form. Use the debug option to ease setting up validation rules, it always prevents the default submit, even when script errors occur. Use submitHandler to implement your own form submit, eg. via Ajax. Use invalidHandler to react when an invalid form is submitted. Use rules and messages to specify which elements to validate, and how. See [rules()](/rules) for more details about specifying validation rules. Use errorClass, errorElement, wrapper, errorLabelContainer, errorContainer, showErrors, success, errorPlacement, highlight, unhighlight, and ignoreTitle to control how invalid elements and error messages are displayed. + +## Usage + +**options** *(Object)* (optional) + + - **debug** *(Any)*: Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a `window.console` property exists). Try to enable when a form is just submitted instead of validation stopping the submit. Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages. $("#myform").validate({ debug: true }); + - **submitHandler** *(Any)*: Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. Example: Submits the form via Ajax, using [jQuery Form plugin](http://jquery.malsup.com/form), when valid. $("#myform").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); } }); Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again. $("#myform").validate({ submitHandler: function(form) { // do other things for a valid form form.submit(); } }); The callback gets passed two arguments: + - **invalidHandler** *(Any)*: Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form. $("#myform").validate({ invalidHandler: function(event, validator) { // 'this' refers to the form var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } } }); The callback gets passed two arguments: + - **ignore** *(Any)*: Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. Example: Ignores all elements with the class "ignore" when validating. $("#myform").validate({ ignore: ".ignore" }); + - **rules** *(Any)*: Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). $("#myform").validate({ rules: { // simple rule, converted to {required:true} name: "required", // compound rule email: { required: true, email: true } } }); Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email. $("#myform").validate({ rules: { contact: { required: true, email: { depends: function(element) { return $("#contactform_email").is(":checked"); } } } } }); Example: Configure a rule that requires a parameter, along with a `depends` callback. $("#myform").validate({ rules: { // at least 15€ when bonus material is included pay_what_you_want: { required: true min: { // min needs a parameter passed to it param: 15, depends: function(element) { return $("#bonus-material").is(":checked"); } } } } }); + - **messages** *(Any)*: Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email. $("#myform").validate({ rules: { name: "required", email: { required: true, email: true } }, messages: { name: "Please specify your name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" } } }); Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places. $("#myform").validate({ rules: { name: { required: true, minlength: 2 } }, messages: { name: { required: "We need your email address to contact you", minlength: jQuery.validator.format("At least {0} characters required!") } } }); + - **groups** *(Any)*: Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messags in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); + - **normalizer** *(Any)*: Prepares/transforms the elements value for validation. See [normalizer docs](/normalizer/) for more details. + - **onsubmit** *(Any)*: Validate the form on submit. Set to false to use only other events for validation. Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise). $("#myform").validate({ onsubmit: false }); + - **onfocusout** *(Any)*: Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables focusout validation. $("#myform").validate({ onfocusout: false }); The callback gets passed two arguments: + - **onkeyup** *(Any)*: Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onkeyup validation. $("#myform").validate({ onkeyup: false }); The callback gets passed two arguments: + - **onclick** *(Any)*: Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onclick validation of checkboxes, radio buttons, and select elements. $("#myform").validate({ onclick: false }); The callback gets passed two arguments: + - **focusInvalid** *(Any)*: Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. Example: Disables focusing of invalid elements. $("#myform").validate({ focusInvalid: false }); + - **focusCleanup** *(Any)*: If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused. $("#myform").validate({ focusCleanup: true }); + - **errorClass** *(Any)*: Use this class to create error labels, to look for existing error labels and to add it to invalid elements. Example: Sets the error class to "invalid". $("#myform").validate({ errorClass: "invalid" }); + - **validClass** *(Any)*: This class is added to an element after it was validated and considered valid. Example: Sets the valid class to "success". $("#myform").validate({ validClass: "success" }); + - **errorElement** *(Any)*: Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). Example: Sets the error element to "em". $("#myform").validate({ errorElement: "em" }); + - **wrapper** *(Any)*: Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container. $("#myform").validate({ wrapper: "li" }); + - **errorLabelContainer** *(Any)*: Hide and show this container when validating. Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages. $("#myform").validate({ errorLabelContainer: "#messageBox", wrapper: "li", submitHandler: function() { alert("Submitted!") } }); + - **errorContainer** *(Any)*: Hide and show this container when validating. Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option). $("#myform").validate({ errorContainer: "#messageBox1, #messageBox2", errorLabelContainer: "#messageBox1 ul", wrapper: "li", debug:true, submitHandler: function() { alert("Submitted!") } }); + - **showErrors** *(Any)*: A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display. $("#myform").validate({ showErrors: function(errorMap, errorList) { $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); this.defaultShowErrors(); } }); The callback gets passed two arguments: + - **errorPlacement** *(Any)*: Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ errorPlacement: function(error, element) { error.appendTo( element.parent("td").next("td") ); } }); The callback gets passed two arguments: + - **success** *(Any)*: If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". Example: Add a class "valid" to valid elements, styled via CSS. $("#myform").validate({ success: "valid", submitHandler: function() { alert("Submitted!") } }); Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!". $("#myform").validate({ success: function(label) { label.addClass("valid").text("Ok!") }, submitHandler: function() { alert("Submitted!") } }); The callback gets passed two arguments: + - **highlight** *(Any)*: How to highlight invalid fields. Override to decide which fields and how to highlight. Example: Highlights an invalid element by fading it out and in again. $("#myform").validate({ highlight: function(element, errorClass) { $(element).fadeOut(function() { $(element).fadeIn(); }); } }); Example: Adds the error class to both the invalid element and its label $("#myform").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.id + "]") .addClass(errorClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.id + "]") .removeClass(errorClass); } }); The callback gets passed three arguments: + - **unhighlight** *(Any)*: Called to revert changes made by option highlight, same arguments as highlight. + - **ignoreTitle** *(Any)*: Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); diff --git a/convert_entries.py b/convert_entries.py new file mode 100644 index 0000000..5ebfe18 --- /dev/null +++ b/convert_entries.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python3 +""" +Convert XML entry files to Markdown format for Jekyll. +""" + +import os +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def clean_text(text): + """Clean and normalize text content.""" + if not text: + return "" + # Remove excessive whitespace + text = re.sub(r'\s+', ' ', text.strip()) + return text + + +def convert_html_entities(text): + """Convert common HTML entities.""" + if not text: + return "" + text = text.replace('<', '<') + text = text.replace('>', '>') + text = text.replace('&', '&') + text = text.replace('"', '"') + return text + + +def extract_text_with_html(elem): + """Extract text and HTML content from an element, preserving structure.""" + if elem is None: + return "" + + # Get all text including from children + parts = [] + if elem.text: + parts.append(elem.text) + + for child in elem: + # Handle special elements + if child.tag == 'code': + code_text = ''.join(child.itertext()) + parts.append(f'`{code_text}`') + elif child.tag == 'p': + p_text = extract_text_with_html(child) + parts.append(f'\n\n{p_text}') + elif child.tag == 'a': + link_text = ''.join(child.itertext()) + href = child.get('href', '') + parts.append(f'[{link_text}]({href})') + else: + parts.append(''.join(child.itertext())) + + if child.tail: + parts.append(child.tail) + + return ''.join(parts) + + +def parse_signature(sig_elem): + """Parse a signature element and return markdown.""" + lines = [] + + # Get description if present + desc_elem = sig_elem.find('desc') + if desc_elem is not None: + desc_text = extract_text_with_html(desc_elem) + if desc_text: + lines.append(clean_text(desc_text)) + lines.append("") + + # Get arguments + for arg in sig_elem.findall('argument'): + arg_name = arg.get('name', 'argument') + arg_type = arg.get('type', 'Any') + optional = arg.get('optional', 'false') == 'true' + + arg_desc_elem = arg.find('desc') + arg_desc = "" + if arg_desc_elem is not None: + arg_desc = extract_text_with_html(arg_desc_elem) + + opt_str = " (optional)" if optional else "" + lines.append(f"**{arg_name}** *({arg_type})*{opt_str}") + if arg_desc: + lines.append(f": {clean_text(arg_desc)}") + lines.append("") + + # Handle nested properties + for prop in arg.findall('property'): + prop_name = prop.get('name', 'property') + prop_type = prop.get('type', 'Any') + prop_desc_elem = prop.find('desc') + prop_desc = "" + if prop_desc_elem is not None: + prop_desc = extract_text_with_html(prop_desc_elem) + + lines.append(f" - **{prop_name}** *({prop_type})*: {clean_text(prop_desc)}") + + if arg.findall('property'): + lines.append("") + + return '\n'.join(lines) + + +def parse_example(example_elem): + """Parse an example element and return markdown.""" + lines = [] + + # Get description + desc_elem = example_elem.find('desc') + if desc_elem is not None: + desc_text = extract_text_with_html(desc_elem) + if desc_text: + lines.append(clean_text(desc_text)) + lines.append("") + + # Get code + code_elem = example_elem.find('code') + if code_elem is not None: + code_text = code_elem.text or "" + # Handle CDATA + if code_text: + lines.append("```javascript") + lines.append(code_text.strip()) + lines.append("```") + lines.append("") + + # Get HTML + html_elem = example_elem.find('html') + if html_elem is not None: + html_text = html_elem.text or "" + if html_text: + lines.append("```html") + lines.append(html_text.strip()) + lines.append("```") + lines.append("") + + return '\n'.join(lines) + + +def convert_xml_to_markdown(xml_path): + """Convert an XML entry file to Markdown format.""" + tree = ET.parse(xml_path) + root = tree.getroot() + + # Extract metadata + entry_name = root.get('name', '') + entry_type = root.get('type', 'method') + return_type = root.get('return', '') + + # Extract title + title_elem = root.find('title') + title = title_elem.text if title_elem is not None else entry_name + + # Extract description + desc_elem = root.find('desc') + desc = extract_text_with_html(desc_elem) if desc_elem is not None else "" + + # Extract long description + longdesc_elem = root.find('longdesc') + longdesc = extract_text_with_html(longdesc_elem) if longdesc_elem is not None else "" + + # Extract sample (for selectors) + sample_elem = root.find('sample') + sample = sample_elem.text if sample_elem is not None else "" + + # Extract category + category_elem = root.find('category') + category = category_elem.get('slug', 'methods') if category_elem is not None else 'methods' + + # Start building markdown + lines = [] + + # Front matter + lines.append("---") + lines.append(f"title: {title}") + lines.append(f"entry_name: {entry_name}") + lines.append(f"entry_type: {entry_type}") + if return_type: + lines.append(f"return_type: {return_type}") + lines.append(f"category: {category}") + lines.append("layout: default") + lines.append("---") + lines.append("") + + # Title + lines.append(f"# {title}") + lines.append("") + + # Sample (for selectors) + if sample: + lines.append(f"**Selector:** `{sample}`") + lines.append("") + + # Description + if desc: + lines.append(clean_text(desc)) + lines.append("") + + # Long description + if longdesc: + lines.append("## Description") + lines.append("") + lines.append(clean_text(longdesc)) + lines.append("") + + # Signatures + signatures = root.findall('signature') + if signatures: + if len(signatures) == 1: + lines.append("## Usage") + lines.append("") + lines.append(parse_signature(signatures[0])) + else: + lines.append("## Usage") + lines.append("") + for i, sig in enumerate(signatures, 1): + if len(signatures) > 1: + lines.append(f"### Form {i}") + lines.append("") + lines.append(parse_signature(sig)) + + # Examples + examples = root.findall('example') + if examples: + lines.append("## Examples") + lines.append("") + for i, example in enumerate(examples, 1): + if len(examples) > 1: + lines.append(f"### Example {i}") + lines.append("") + lines.append(parse_example(example)) + + return '\n'.join(lines) + + +def main(): + """Main conversion function.""" + entries_dir = Path('/home/runner/work/validation-content/validation-content/entries') + output_dir = Path('/home/runner/work/validation-content/validation-content/_entries') + + # Create output directory + output_dir.mkdir(exist_ok=True) + + # Convert each XML file + xml_files = sorted(entries_dir.glob('*.xml')) + print(f"Found {len(xml_files)} XML files to convert") + + for xml_file in xml_files: + print(f"Converting {xml_file.name}...") + try: + markdown_content = convert_xml_to_markdown(xml_file) + + # Create output filename + output_file = output_dir / xml_file.with_suffix('.md').name + + # Write markdown file + output_file.write_text(markdown_content) + print(f" -> {output_file.name}") + except Exception as e: + print(f" ERROR: {e}") + + print(f"\nConversion complete! {len(xml_files)} files converted to {output_dir}") + + +if __name__ == '__main__': + main() From a0ffcfc1a7d1731d057e475792734f51da0515b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:32:47 +0000 Subject: [PATCH 05/22] Improve XML to Markdown conversion formatting Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/3cd3a909-bae0-4790-b477-0bccbaf09aac Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- _entries/Validator.element.md | 3 +- _entries/Validator.numberOfInvalids.md | 3 +- _entries/Validator.showErrors.md | 3 +- _entries/accept-method.md | 3 +- _entries/equalTo-method.md | 3 +- _entries/extension-method.md | 3 +- _entries/jQuery.validator.addClassRules.md | 9 +- _entries/jQuery.validator.addMethod.md | 23 ++- _entries/jQuery.validator.format.md | 9 +- _entries/jQuery.validator.setDefaults.md | 3 +- _entries/max-method.md | 3 +- _entries/maxlength-method.md | 3 +- _entries/min-method.md | 3 +- _entries/minlength-method.md | 3 +- _entries/normalizer.md | 3 +- _entries/range-method.md | 3 +- _entries/rangelength-method.md | 3 +- _entries/remote-method.md | 3 +- _entries/required-method.md | 6 +- _entries/rules.md | 6 +- _entries/step-method.md | 3 +- _entries/validate.md | 213 ++++++++++++++++++--- convert_entries.py | 54 ++++-- 23 files changed, 295 insertions(+), 73 deletions(-) diff --git a/_entries/Validator.element.md b/_entries/Validator.element.md index 43db960..c0a6102 100644 --- a/_entries/Validator.element.md +++ b/_entries/Validator.element.md @@ -17,7 +17,8 @@ This behaves as validation on blur or keyup, but returns the result. ## Usage **element** *(Selector)* -: An element to validate, must be inside the validated form. + +An element to validate, must be inside the validated form. ## Examples diff --git a/_entries/Validator.numberOfInvalids.md b/_entries/Validator.numberOfInvalids.md index 816f603..b1e948a 100644 --- a/_entries/Validator.numberOfInvalids.md +++ b/_entries/Validator.numberOfInvalids.md @@ -17,7 +17,8 @@ This depends on the internal validator state. It covers all fields only after va ## Usage **errors** *(Object)* -: One or more key/value pairs of input names and messages. + +One or more key/value pairs of input names and messages. ## Examples diff --git a/_entries/Validator.showErrors.md b/_entries/Validator.showErrors.md index 48df127..db1d879 100644 --- a/_entries/Validator.showErrors.md +++ b/_entries/Validator.showErrors.md @@ -17,7 +17,8 @@ Keys have to refer to the names of elements, values are displayed for those elem ## Usage **errors** *(Object)* -: One or more key/value pairs of input names and messages. + +One or more key/value pairs of input names and messages. ## Examples diff --git a/_entries/accept-method.md b/_entries/accept-method.md index b0543a3..80372d4 100644 --- a/_entries/accept-method.md +++ b/_entries/accept-method.md @@ -18,7 +18,8 @@ Uses the HTML5 file API to look at the type attribute of one or more selected fi ## Usage **mimetype** *(String)* -: The allowed type, seperated via ",", defaults to "image/*" + +The allowed type, seperated via ",", defaults to "image/*" ## Examples diff --git a/_entries/equalTo-method.md b/_entries/equalTo-method.md index 8eaac9f..7a40668 100644 --- a/_entries/equalTo-method.md +++ b/_entries/equalTo-method.md @@ -18,7 +18,8 @@ Returns true if the value has the same value as the element specified by the fir ## Usage **other** *(Selector)* -: The selector for the element to compare the current values + +The selector for the element to compare the current values ## Examples diff --git a/_entries/extension-method.md b/_entries/extension-method.md index 80b6389..d9491e3 100644 --- a/_entries/extension-method.md +++ b/_entries/extension-method.md @@ -18,7 +18,8 @@ Returns true if the value ends with one of the specified file extensions. If not ## Usage **extension** *(String)* (optional) -: The allowed file extensions, seperated with "|" (or a comma, ","), defaults to "png|jpe?g|gif". + +The allowed file extensions, seperated with "|" (or a comma, ","), defaults to "png|jpe?g|gif". ## Examples diff --git a/_entries/jQuery.validator.addClassRules.md b/_entries/jQuery.validator.addClassRules.md index b055f53..1af97a0 100644 --- a/_entries/jQuery.validator.addClassRules.md +++ b/_entries/jQuery.validator.addClassRules.md @@ -15,15 +15,18 @@ Add a compound class method - useful to refactor common combinations of rules in ### Form 1 **name** *(String)* -: The name of the class rule to add + +The name of the class rule to add **rules** *(Object)* -: The compound rules (see example) + +The compound rules (see example) ### Form 2 **rules** *(Object)* -: A map of className-rules pairs (see example). + +A map of className-rules pairs (see example). ## Examples diff --git a/_entries/jQuery.validator.addMethod.md b/_entries/jQuery.validator.addMethod.md index 3930581..a776c3c 100644 --- a/_entries/jQuery.validator.addMethod.md +++ b/_entries/jQuery.validator.addMethod.md @@ -17,17 +17,28 @@ For simple one-off validation, you can use the bundled `pattern` method (in addi ## Usage **name** *(String)* -: The name of the method used to identify it and referencing it; this must be a valid JavaScript identifier + +The name of the method used to identify it and referencing it; this must be a valid JavaScript identifier **method** *(Function)* -: The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters. - - **value** *(String)*: the current value of the validated element - - **element** *(Element)*: the element to be validated - - **params** *(Object)*: parameters specified for the method, e.g. for min: 5, the parameter is 5, for range: [1, 5] it's [1, 5] +The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters. + + **value** *(String)* + + the current value of the validated element + + **element** *(Element)* + + the element to be validated + + **params** *(Object)* + + parameters specified for the method, e.g. for min: 5, the parameter is 5, for range: [1, 5] it's [1, 5] **message** *(String)* (optional) -: The default message to display for this method. Can be a function created by ''jQuery.validator.format(value)''. When undefined, an existing message is used (handy for localization), otherwise the field-specific messages have to be defined. + +The default message to display for this method. Can be a function created by ''jQuery.validator.format(value)''. When undefined, an existing message is used (handy for localization), otherwise the field-specific messages have to be defined. ## Examples diff --git a/_entries/jQuery.validator.format.md b/_entries/jQuery.validator.format.md index e8dc97c..a650b81 100644 --- a/_entries/jQuery.validator.format.md +++ b/_entries/jQuery.validator.format.md @@ -17,13 +17,16 @@ One or more arguments can be passed, in addition to the string template itself, ## Usage **template** *(String)* -: The string to format. + +The string to format. **argument** *(Object)* -: The first argument to insert, or an array of Strings to insert + +The first argument to insert, or an array of Strings to insert **argumentN...** *(Object)* -: The second etc. argument to insert + +The second etc. argument to insert ## Examples diff --git a/_entries/jQuery.validator.setDefaults.md b/_entries/jQuery.validator.setDefaults.md index 2f820c8..89fa70f 100644 --- a/_entries/jQuery.validator.setDefaults.md +++ b/_entries/jQuery.validator.setDefaults.md @@ -17,7 +17,8 @@ Accepts everything that [validate()](/validate) accepts. ## Usage **options** *(Object)* -: Options to set as default. + +Options to set as default. ## Examples diff --git a/_entries/max-method.md b/_entries/max-method.md index f03340a..60150d7 100644 --- a/_entries/max-method.md +++ b/_entries/max-method.md @@ -18,7 +18,8 @@ Works with text inputs. To exclude the maximum value, subtract Number.MIN_VALUE ## Usage **value** *(Number)* -: Maximum value required + +Maximum value required ## Examples diff --git a/_entries/maxlength-method.md b/_entries/maxlength-method.md index d4f4573..0583a03 100644 --- a/_entries/maxlength-method.md +++ b/_entries/maxlength-method.md @@ -18,7 +18,8 @@ Return false if the element is some kind of text input and its value is too long ## Usage **length** *(Number)* -: Maximum number of characters required + +Maximum number of characters required ## Examples diff --git a/_entries/min-method.md b/_entries/min-method.md index 3023c55..7736bea 100644 --- a/_entries/min-method.md +++ b/_entries/min-method.md @@ -18,7 +18,8 @@ Works with text inputs. To exclude the minimum value, add Number.MIN_VALUE to th ## Usage **value** *(Number)* -: Minimum value required + +Minimum value required ## Examples diff --git a/_entries/minlength-method.md b/_entries/minlength-method.md index 0110371..beb4e14 100644 --- a/_entries/minlength-method.md +++ b/_entries/minlength-method.md @@ -18,7 +18,8 @@ Return false if the element is some kind of text input and its value is too shor ## Usage **length** *(Number)* -: Minimum number of characters required + +Minimum number of characters required ## Examples diff --git a/_entries/normalizer.md b/_entries/normalizer.md index f441b63..cb15ecd 100644 --- a/_entries/normalizer.md +++ b/_entries/normalizer.md @@ -18,7 +18,8 @@ Transform the value of an element and the result for validation instead of the i ## Usage **value** *(String)* -: The value of the element. + +The value of the element. ## Examples diff --git a/_entries/range-method.md b/_entries/range-method.md index 506804a..a1071cc 100644 --- a/_entries/range-method.md +++ b/_entries/range-method.md @@ -18,7 +18,8 @@ Works with text inputs. To exclude the maximum value, subtract Number.MIN_VALUE ## Usage **range** *(Array)* -: Value range required + +Value range required ## Examples diff --git a/_entries/rangelength-method.md b/_entries/rangelength-method.md index dabcff5..557377f 100644 --- a/_entries/rangelength-method.md +++ b/_entries/rangelength-method.md @@ -18,7 +18,8 @@ Return false if the element is some kind of text input and its length is too sho ## Usage **range** *(Array)* -: Value range required + +Value range required ## Examples diff --git a/_entries/remote-method.md b/_entries/remote-method.md index f4ef22d..81b0e1d 100644 --- a/_entries/remote-method.md +++ b/_entries/remote-method.md @@ -18,7 +18,8 @@ The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a ke ## Usage **options** *(Object)* -: For the URL of the resource to request for serverside validation (String) or options to fully customize the request, see [jQuery.ajax](https://api.jquery.com/jQuery.ajax) for details. These options deep-extend the defaults (`dataType:"json", data:{nameOfTheElement:valueOfTheElement}`). Any options you provide will override the defaults. + +For the URL of the resource to request for serverside validation (String) or options to fully customize the request, see [jQuery.ajax](https://api.jquery.com/jQuery.ajax) for details. These options deep-extend the defaults (`dataType:"json", data:{nameOfTheElement:valueOfTheElement}`). Any options you provide will override the defaults. ## Examples diff --git a/_entries/required-method.md b/_entries/required-method.md index ee709d8..8734bb5 100644 --- a/_entries/required-method.md +++ b/_entries/required-method.md @@ -26,14 +26,16 @@ The element is always required. Makes the element required, depending on the result of the given expression. **dependency-expression** *(String)* -: An expression (String) that is evaluated in the context of the element's form, making the field required only if the expression returns more than one element. Very often your expression will use selector filters such as `#foo:checked`, `#foo:filled`, `#foo:visible`. This plugin provides [custom selectors for that purpose](/category/selectors/). + +An expression (String) that is evaluated in the context of the element's form, making the field required only if the expression returns more than one element. Very often your expression will use selector filters such as `#foo:checked`, `#foo:filled`, `#foo:visible`. This plugin provides [custom selectors for that purpose](/category/selectors/). ### Form 3 Makes the element required, depending on the result of the given callback. **dependency-callback** *(Function)* -: The function is executed with the element as it's only argument: If it returns true, the element is required. + +The function is executed with the element as it's only argument: If it returns true, the element is required. ## Examples diff --git a/_entries/rules.md b/_entries/rules.md index 99b905e..27700dc 100644 --- a/_entries/rules.md +++ b/_entries/rules.md @@ -28,7 +28,8 @@ Add rules **"add"** *(String)* **rules** *(Object)* -: The rules to add. Accepts the same format as the rules-option of the validate-method. + +The rules to add. Accepts the same format as the rules-option of the validate-method. ### Form 3 @@ -37,7 +38,8 @@ Remove rules **"remove"** *(String)* **rules** *(Object)* -: The space-seperated names of rules to remove and return. If left unspecified, removes and returns all rules. Manipulates only rules specified via rules-option or via rules("add"). + +The space-seperated names of rules to remove and return. If left unspecified, removes and returns all rules. Manipulates only rules specified via rules-option or via rules("add"). ## Examples diff --git a/_entries/step-method.md b/_entries/step-method.md index d770d9a..6b5e1b0 100644 --- a/_entries/step-method.md +++ b/_entries/step-method.md @@ -18,7 +18,8 @@ Works with text inputs. No support for input types: date, datetime, datetime-loc ## Usage **value** *(Number)* -: Step value required + +Step value required ## Examples diff --git a/_entries/validate.md b/_entries/validate.md index acf97c0..17fcbbe 100644 --- a/_entries/validate.md +++ b/_entries/validate.md @@ -19,29 +19,190 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **options** *(Object)* (optional) - - **debug** *(Any)*: Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a `window.console` property exists). Try to enable when a form is just submitted instead of validation stopping the submit. Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages. $("#myform").validate({ debug: true }); - - **submitHandler** *(Any)*: Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. Example: Submits the form via Ajax, using [jQuery Form plugin](http://jquery.malsup.com/form), when valid. $("#myform").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); } }); Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again. $("#myform").validate({ submitHandler: function(form) { // do other things for a valid form form.submit(); } }); The callback gets passed two arguments: - - **invalidHandler** *(Any)*: Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form. $("#myform").validate({ invalidHandler: function(event, validator) { // 'this' refers to the form var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } } }); The callback gets passed two arguments: - - **ignore** *(Any)*: Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. Example: Ignores all elements with the class "ignore" when validating. $("#myform").validate({ ignore: ".ignore" }); - - **rules** *(Any)*: Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). $("#myform").validate({ rules: { // simple rule, converted to {required:true} name: "required", // compound rule email: { required: true, email: true } } }); Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email. $("#myform").validate({ rules: { contact: { required: true, email: { depends: function(element) { return $("#contactform_email").is(":checked"); } } } } }); Example: Configure a rule that requires a parameter, along with a `depends` callback. $("#myform").validate({ rules: { // at least 15€ when bonus material is included pay_what_you_want: { required: true min: { // min needs a parameter passed to it param: 15, depends: function(element) { return $("#bonus-material").is(":checked"); } } } } }); - - **messages** *(Any)*: Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email. $("#myform").validate({ rules: { name: "required", email: { required: true, email: true } }, messages: { name: "Please specify your name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" } } }); Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places. $("#myform").validate({ rules: { name: { required: true, minlength: 2 } }, messages: { name: { required: "We need your email address to contact you", minlength: jQuery.validator.format("At least {0} characters required!") } } }); - - **groups** *(Any)*: Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messags in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); - - **normalizer** *(Any)*: Prepares/transforms the elements value for validation. See [normalizer docs](/normalizer/) for more details. - - **onsubmit** *(Any)*: Validate the form on submit. Set to false to use only other events for validation. Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise). $("#myform").validate({ onsubmit: false }); - - **onfocusout** *(Any)*: Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables focusout validation. $("#myform").validate({ onfocusout: false }); The callback gets passed two arguments: - - **onkeyup** *(Any)*: Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onkeyup validation. $("#myform").validate({ onkeyup: false }); The callback gets passed two arguments: - - **onclick** *(Any)*: Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onclick validation of checkboxes, radio buttons, and select elements. $("#myform").validate({ onclick: false }); The callback gets passed two arguments: - - **focusInvalid** *(Any)*: Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. Example: Disables focusing of invalid elements. $("#myform").validate({ focusInvalid: false }); - - **focusCleanup** *(Any)*: If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused. $("#myform").validate({ focusCleanup: true }); - - **errorClass** *(Any)*: Use this class to create error labels, to look for existing error labels and to add it to invalid elements. Example: Sets the error class to "invalid". $("#myform").validate({ errorClass: "invalid" }); - - **validClass** *(Any)*: This class is added to an element after it was validated and considered valid. Example: Sets the valid class to "success". $("#myform").validate({ validClass: "success" }); - - **errorElement** *(Any)*: Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). Example: Sets the error element to "em". $("#myform").validate({ errorElement: "em" }); - - **wrapper** *(Any)*: Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container. $("#myform").validate({ wrapper: "li" }); - - **errorLabelContainer** *(Any)*: Hide and show this container when validating. Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages. $("#myform").validate({ errorLabelContainer: "#messageBox", wrapper: "li", submitHandler: function() { alert("Submitted!") } }); - - **errorContainer** *(Any)*: Hide and show this container when validating. Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option). $("#myform").validate({ errorContainer: "#messageBox1, #messageBox2", errorLabelContainer: "#messageBox1 ul", wrapper: "li", debug:true, submitHandler: function() { alert("Submitted!") } }); - - **showErrors** *(Any)*: A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display. $("#myform").validate({ showErrors: function(errorMap, errorList) { $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); this.defaultShowErrors(); } }); The callback gets passed two arguments: - - **errorPlacement** *(Any)*: Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ errorPlacement: function(error, element) { error.appendTo( element.parent("td").next("td") ); } }); The callback gets passed two arguments: - - **success** *(Any)*: If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". Example: Add a class "valid" to valid elements, styled via CSS. $("#myform").validate({ success: "valid", submitHandler: function() { alert("Submitted!") } }); Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!". $("#myform").validate({ success: function(label) { label.addClass("valid").text("Ok!") }, submitHandler: function() { alert("Submitted!") } }); The callback gets passed two arguments: - - **highlight** *(Any)*: How to highlight invalid fields. Override to decide which fields and how to highlight. Example: Highlights an invalid element by fading it out and in again. $("#myform").validate({ highlight: function(element, errorClass) { $(element).fadeOut(function() { $(element).fadeIn(); }); } }); Example: Adds the error class to both the invalid element and its label $("#myform").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.id + "]") .addClass(errorClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.id + "]") .removeClass(errorClass); } }); The callback gets passed three arguments: - - **unhighlight** *(Any)*: Called to revert changes made by option highlight, same arguments as highlight. - - **ignoreTitle** *(Any)*: Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); + **debug** *(Any)* (default: `false`) + + Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a `window.console` property exists). Try to enable when a form is just submitted instead of validation stopping the submit. Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages. $("#myform").validate({ debug: true }); + + **submitHandler** *(Any)* (default: `native form submit`) + + Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. Example: Submits the form via Ajax, using [jQuery Form plugin](http://jquery.malsup.com/form), when valid. $("#myform").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); } }); Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again. $("#myform").validate({ submitHandler: function(form) { // do other things for a valid form form.submit(); } }); The callback gets passed two arguments: + + **form** *(Element)* + + The form currently being validated, as a DOMElement. + + **event** *(Event)* + + The submit event instance. + + **invalidHandler** *(Any)* + + Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form. $("#myform").validate({ invalidHandler: function(event, validator) { // 'this' refers to the form var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } } }); The callback gets passed two arguments: + + **event** *(Event)* + + A custom event object, since this function is bound as an event handler. + + **validator** *(Validator)* + + The validator instance for the current form. + + **ignore** *(Any)* (default: `":hidden"`) + + Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. Example: Ignores all elements with the class "ignore" when validating. $("#myform").validate({ ignore: ".ignore" }); + + **rules** *(Any)* (default: `rules are read from markup (classes, attributes, data)`) + + Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). $("#myform").validate({ rules: { // simple rule, converted to {required:true} name: "required", // compound rule email: { required: true, email: true } } }); Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email. $("#myform").validate({ rules: { contact: { required: true, email: { depends: function(element) { return $("#contactform_email").is(":checked"); } } } } }); Example: Configure a rule that requires a parameter, along with a `depends` callback. $("#myform").validate({ rules: { // at least 15€ when bonus material is included pay_what_you_want: { required: true min: { // min needs a parameter passed to it param: 15, depends: function(element) { return $("#bonus-material").is(":checked"); } } } } }); + + **messages** *(Any)* (default: `the default message for the method used`) + + Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email. $("#myform").validate({ rules: { name: "required", email: { required: true, email: true } }, messages: { name: "Please specify your name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" } } }); Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places. $("#myform").validate({ rules: { name: { required: true, minlength: 2 } }, messages: { name: { required: "We need your email address to contact you", minlength: jQuery.validator.format("At least {0} characters required!") } } }); + + **groups** *(Any)* + + Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messags in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); + + **normalizer** *(Any)* + + Prepares/transforms the elements value for validation. See [normalizer docs](/normalizer/) for more details. + + **onsubmit** *(Any)* (default: `true`) + + Validate the form on submit. Set to false to use only other events for validation. Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise). $("#myform").validate({ onsubmit: false }); + + **onfocusout** *(Any)* + + Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables focusout validation. $("#myform").validate({ onfocusout: false }); The callback gets passed two arguments: + + **element** *(Element)* + + The element currently being validated, as a DOMElement. + + **event** *(Event)* + + The event object for this focusout event. + + **onkeyup** *(Any)* + + Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onkeyup validation. $("#myform").validate({ onkeyup: false }); The callback gets passed two arguments: + + **element** *(Element)* + + The element currently being validated, as a DOMElement. + + **event** *(Event)* + + The event object for this keyup event. + + **onclick** *(Any)* + + Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onclick validation of checkboxes, radio buttons, and select elements. $("#myform").validate({ onclick: false }); The callback gets passed two arguments: + + **element** *(Element)* + + The element currently being validated, as a DOMElement. + + **event** *(Event)* + + The event object for this click event. + + **focusInvalid** *(Any)* (default: `true`) + + Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. Example: Disables focusing of invalid elements. $("#myform").validate({ focusInvalid: false }); + + **focusCleanup** *(Any)* (default: `false`) + + If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused. $("#myform").validate({ focusCleanup: true }); + + **errorClass** *(Any)* (default: `"error"`) + + Use this class to create error labels, to look for existing error labels and to add it to invalid elements. Example: Sets the error class to "invalid". $("#myform").validate({ errorClass: "invalid" }); + + **validClass** *(Any)* (default: `"valid"`) + + This class is added to an element after it was validated and considered valid. Example: Sets the valid class to "success". $("#myform").validate({ validClass: "success" }); + + **errorElement** *(Any)* (default: `"label"`) + + Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). Example: Sets the error element to "em". $("#myform").validate({ errorElement: "em" }); + + **wrapper** *(Any)* (default: `window`) + + Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container. $("#myform").validate({ wrapper: "li" }); + + **errorLabelContainer** *(Any)* + + Hide and show this container when validating. Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages. $("#myform").validate({ errorLabelContainer: "#messageBox", wrapper: "li", submitHandler: function() { alert("Submitted!") } }); + + **errorContainer** *(Any)* + + Hide and show this container when validating. Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option). $("#myform").validate({ errorContainer: "#messageBox1, #messageBox2", errorLabelContainer: "#messageBox1 ul", wrapper: "li", debug:true, submitHandler: function() { alert("Submitted!") } }); + + **showErrors** *(Any)* + + A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display. $("#myform").validate({ showErrors: function(errorMap, errorList) { $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); this.defaultShowErrors(); } }); The callback gets passed two arguments: + + **errorMap** *(Object)* + + Key/value pairs, where the key refers to the name of an input field, values the message to be displayed for that input. + + **errorList** *(Array)* + + An array for all currently validated elements. Contains objects with the following two properties: + + **message** *(String)* + + The message to be displayed for an input. + + **element** *(Element)* + + The DOMElement for this entry. + + **errorPlacement** *(Any)* (default: `Places the error label after the invalid element`) + + Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ errorPlacement: function(error, element) { error.appendTo( element.parent("td").next("td") ); } }); The callback gets passed two arguments: + + **error** *(jQuery)* + + The error label to insert into the DOM. + + **element** *(jQuery)* + + The validated input, for relative positioning. + + **success** *(Any)* + + If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". Example: Add a class "valid" to valid elements, styled via CSS. $("#myform").validate({ success: "valid", submitHandler: function() { alert("Submitted!") } }); Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!". $("#myform").validate({ success: function(label) { label.addClass("valid").text("Ok!") }, submitHandler: function() { alert("Submitted!") } }); The callback gets passed two arguments: + + **label** *(jQuery)* + + The error label. Use to add a class or replace the text content. + + **element** *(Element)* + + The element currently being validated, as a DOMElement. + + **highlight** *(Any)* (default: `Adds errorClass (see the option) to the element`) + + How to highlight invalid fields. Override to decide which fields and how to highlight. Example: Highlights an invalid element by fading it out and in again. $("#myform").validate({ highlight: function(element, errorClass) { $(element).fadeOut(function() { $(element).fadeIn(); }); } }); Example: Adds the error class to both the invalid element and its label $("#myform").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.id + "]") .addClass(errorClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.id + "]") .removeClass(errorClass); } }); The callback gets passed three arguments: + + **element** *(Element)* + + The invalid DOM element, usually an `input`. + + **errorClass** *(String)* + + Current value of the `errorClass` option. + + **validClass** *(String)* + + Current value of the `validClass` option. + + **unhighlight** *(Any)* (default: `Removes the errorClass`) + + Called to revert changes made by option highlight, same arguments as highlight. + + **ignoreTitle** *(Any)* (default: `false`) + + Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); diff --git a/convert_entries.py b/convert_entries.py index 5ebfe18..4162429 100644 --- a/convert_entries.py +++ b/convert_entries.py @@ -77,6 +77,7 @@ def parse_signature(sig_elem): arg_name = arg.get('name', 'argument') arg_type = arg.get('type', 'Any') optional = arg.get('optional', 'false') == 'true' + default_val = arg.get('default', '') arg_desc_elem = arg.find('desc') arg_desc = "" @@ -84,28 +85,51 @@ def parse_signature(sig_elem): arg_desc = extract_text_with_html(arg_desc_elem) opt_str = " (optional)" if optional else "" - lines.append(f"**{arg_name}** *({arg_type})*{opt_str}") + default_str = f" (default: `{default_val}`)" if default_val else "" + lines.append(f"**{arg_name}** *({arg_type})*{opt_str}{default_str}") if arg_desc: - lines.append(f": {clean_text(arg_desc)}") + lines.append("") + lines.append(clean_text(arg_desc)) lines.append("") - # Handle nested properties - for prop in arg.findall('property'): - prop_name = prop.get('name', 'property') - prop_type = prop.get('type', 'Any') - prop_desc_elem = prop.find('desc') - prop_desc = "" - if prop_desc_elem is not None: - prop_desc = extract_text_with_html(prop_desc_elem) - - lines.append(f" - **{prop_name}** *({prop_type})*: {clean_text(prop_desc)}") - - if arg.findall('property'): - lines.append("") + # Handle nested properties (recursively) + parse_properties(arg, lines, indent=1) return '\n'.join(lines) +def parse_properties(parent_elem, lines, indent=0): + """Recursively parse property elements.""" + for prop in parent_elem.findall('property'): + prop_name = prop.get('name', 'property') + prop_type = prop.get('type', 'Any') + default_val = prop.get('default', '') + + prop_desc_elem = prop.find('desc') + prop_desc = "" + if prop_desc_elem is not None: + prop_desc = extract_text_with_html(prop_desc_elem) + + indent_str = " " * indent + default_str = f" (default: `{default_val}`)" if default_val else "" + + # Format the property line + lines.append(f"{indent_str}**{prop_name}** *({prop_type})*{default_str}") + if prop_desc: + lines.append("") + # Indent description text + desc_lines = clean_text(prop_desc).split('\n') + for desc_line in desc_lines: + if desc_line.strip(): + lines.append(f"{indent_str}{desc_line}") + lines.append("") + + # Recursively handle nested properties + nested_props = prop.findall('property') + if nested_props: + parse_properties(prop, lines, indent + 1) + + def parse_example(example_elem): """Parse an example element and return markdown.""" lines = [] From 85198170546ba232ddefb5cb5b47a8e659faa49f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:33:30 +0000 Subject: [PATCH 06/22] Add conversion documentation and finalize configuration Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/3cd3a909-bae0-4790-b477-0bccbaf09aac Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- CONVERSION_NOTES.md | 77 +++++++++++++++++++++++++++++++++++++++++++++ _config.yml | 1 + 2 files changed, 78 insertions(+) create mode 100644 CONVERSION_NOTES.md diff --git a/CONVERSION_NOTES.md b/CONVERSION_NOTES.md new file mode 100644 index 0000000..b4202bd --- /dev/null +++ b/CONVERSION_NOTES.md @@ -0,0 +1,77 @@ +# XML to Markdown Conversion Notes + +## Overview + +The `entries/` directory contained 39 XML files that defined the API documentation for individual validation methods, selectors, and validator functions. These have been converted to Markdown format and moved to the `_entries/` directory for use with Jekyll. + +## Conversion Process + +1. **Script**: `convert_entries.py` - Python script that parses XML and generates Markdown +2. **Source**: `entries/*.xml` (39 files) +3. **Output**: `_entries/*.md` (39 files) + +## Conversion Details + +Each XML file was transformed as follows: + +### Front Matter +- `title`: From `` element +- `entry_name`: From `name` attribute of root `<entry>` +- `entry_type`: From `type` attribute (method, selector, validator) +- `return_type`: From `return` attribute (if present) +- `category`: From `<category slug="">` element +- `layout`: Set to "default" + +### Content Structure +- **Title**: H1 heading from `<title>` +- **Sample**: For selectors, the selector syntax from `<sample>` +- **Description**: From `<desc>` element +- **Long Description**: From `<longdesc>` element (with HTML preserved as markdown) +- **Usage/Signatures**: From `<signature>` elements with nested arguments and properties +- **Examples**: From `<example>` elements with JavaScript and HTML code blocks + +## Jekyll Configuration + +The `_config.yml` has been configured to: +- Define `entries` as a collection +- Output entries with permalink pattern `/:name/` +- Apply the default layout to all entries +- Exclude the old `entries/` directory and conversion script from builds + +## URL Mapping + +With the permalink configuration, entries are accessible at: +- `/validate/` → `_entries/validate.md` +- `/required-method/` → `_entries/required-method.md` +- `/blank-selector/` → `_entries/blank-selector.md` +- etc. + +This matches the link structure already present in `documentation.md`. + +## Original XML Files + +The original XML files in the `entries/` directory are: +- Excluded from Jekyll processing (in `_config.yml`) +- Kept for reference +- Can be removed once the conversion is verified in production + +## Testing + +To verify the conversion: +1. Check that all 39 entries are present in `_entries/` +2. Verify front matter is correct for each file +3. Ensure links in `documentation.md` resolve correctly +4. Test the GitHub Pages deployment + +## Files Created/Modified + +**Created:** +- `_entries/*.md` (39 files) +- `convert_entries.py` +- This file (`CONVERSION_NOTES.md`) + +**Modified:** +- `_config.yml` - Updated collections, permalink, and excludes + +**Preserved (for reference):** +- `entries/*.xml` (39 files) - Original XML sources diff --git a/_config.yml b/_config.yml index e084902..838a620 100644 --- a/_config.yml +++ b/_config.yml @@ -26,6 +26,7 @@ exclude: - GITHUB_PAGES_SETUP.md - entries - convert_entries.py + - CONVERSION_NOTES.md # Collections collections: From 285f5036ef12d29d884b87f04c881cf27b24d8ad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Apr 2026 11:34:43 +0000 Subject: [PATCH 07/22] Make conversion script paths relative for portability Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/3cd3a909-bae0-4790-b477-0bccbaf09aac Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- convert_entries.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/convert_entries.py b/convert_entries.py index 4162429..8021c83 100644 --- a/convert_entries.py +++ b/convert_entries.py @@ -264,8 +264,9 @@ def convert_xml_to_markdown(xml_path): def main(): """Main conversion function.""" - entries_dir = Path('/home/runner/work/validation-content/validation-content/entries') - output_dir = Path('/home/runner/work/validation-content/validation-content/_entries') + script_dir = Path(__file__).parent + entries_dir = script_dir / 'entries' + output_dir = script_dir / '_entries' # Create output directory output_dir.mkdir(exist_ok=True) From 0bfb7b9ae3aa1972073ac943a5e1d52d532ed1da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:27:11 +0000 Subject: [PATCH 08/22] Remove old unused files and clean up repository structure Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/5608e6dd-347c-4281-81b1-3c53a3aeeac1 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- Gruntfile.js | 40 -- README.md | 4 +- _config.yml | 8 - categories.xml | 16 - config-sample.json | 9 - convert_entries.py | 296 --------- entries/Validator.destroy.xml | 28 - entries/Validator.element.xml | 20 - entries/Validator.form.xml | 17 - entries/Validator.numberOfInvalids.xml | 23 - entries/Validator.resetForm.xml | 17 - entries/Validator.showErrors.xml | 22 - entries/accept-method.xml | 43 -- entries/blank-selector.xml | 25 - entries/creditcard-method.xml | 31 - entries/date-method.xml | 30 - entries/dateISO-method.xml | 29 - entries/digits-method.xml | 29 - entries/email-method.xml | 31 - entries/equalTo-method.xml | 38 -- entries/extension-method.xml | 37 -- entries/filled-selector.xml | 25 - entries/jQuery.validator.addClassRules.xml | 46 -- entries/jQuery.validator.addMethod.xml | 57 -- entries/jQuery.validator.format.xml | 30 - entries/jQuery.validator.methods.xml | 15 - entries/jQuery.validator.setDefaults.xml | 21 - entries/max-method.xml | 35 - entries/maxlength-method.xml | 41 -- entries/min-method.xml | 35 - entries/minlength-method.xml | 41 -- entries/normalizer.xml | 128 ---- entries/number-method.xml | 29 - entries/phoneUS-method.xml | 29 - entries/range-method.xml | 35 - entries/rangelength-method.xml | 41 -- entries/remote-method.xml | 55 -- entries/require_from_group-method.xml | 44 -- entries/required-method.xml | 163 ----- entries/rules.xml | 72 -- entries/step-method.xml | 35 - entries/unchecked-selector.xml | 38 -- entries/url-method.xml | 29 - entries/valid.xml | 31 - entries/validate.xml | 544 --------------- entries2html.xsl | 30 - notes.xsl | 3 - package-lock.json | 733 --------------------- package.json | 27 - pages/contribute.md | 11 - pages/documentation.md | 212 ------ pages/index.html | 59 -- pages/reference.md | 129 ---- 53 files changed, 2 insertions(+), 3614 deletions(-) delete mode 100644 Gruntfile.js delete mode 100644 categories.xml delete mode 100644 config-sample.json delete mode 100644 convert_entries.py delete mode 100644 entries/Validator.destroy.xml delete mode 100644 entries/Validator.element.xml delete mode 100644 entries/Validator.form.xml delete mode 100644 entries/Validator.numberOfInvalids.xml delete mode 100644 entries/Validator.resetForm.xml delete mode 100644 entries/Validator.showErrors.xml delete mode 100644 entries/accept-method.xml delete mode 100644 entries/blank-selector.xml delete mode 100644 entries/creditcard-method.xml delete mode 100644 entries/date-method.xml delete mode 100644 entries/dateISO-method.xml delete mode 100644 entries/digits-method.xml delete mode 100644 entries/email-method.xml delete mode 100644 entries/equalTo-method.xml delete mode 100644 entries/extension-method.xml delete mode 100644 entries/filled-selector.xml delete mode 100644 entries/jQuery.validator.addClassRules.xml delete mode 100644 entries/jQuery.validator.addMethod.xml delete mode 100644 entries/jQuery.validator.format.xml delete mode 100644 entries/jQuery.validator.methods.xml delete mode 100644 entries/jQuery.validator.setDefaults.xml delete mode 100644 entries/max-method.xml delete mode 100644 entries/maxlength-method.xml delete mode 100644 entries/min-method.xml delete mode 100644 entries/minlength-method.xml delete mode 100644 entries/normalizer.xml delete mode 100644 entries/number-method.xml delete mode 100644 entries/phoneUS-method.xml delete mode 100644 entries/range-method.xml delete mode 100644 entries/rangelength-method.xml delete mode 100644 entries/remote-method.xml delete mode 100644 entries/require_from_group-method.xml delete mode 100644 entries/required-method.xml delete mode 100644 entries/rules.xml delete mode 100644 entries/step-method.xml delete mode 100644 entries/unchecked-selector.xml delete mode 100644 entries/url-method.xml delete mode 100644 entries/valid.xml delete mode 100644 entries/validate.xml delete mode 100644 entries2html.xsl delete mode 100644 notes.xsl delete mode 100644 package-lock.json delete mode 100644 package.json delete mode 100644 pages/contribute.md delete mode 100644 pages/documentation.md delete mode 100644 pages/index.html delete mode 100644 pages/reference.md diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index dfc6e63..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,40 +0,0 @@ -module.exports = function( grunt ) { - -grunt.loadNpmTasks( "grunt-jquery-content" ); - -grunt.initConfig({ - xmllint: { - all: [ - "entries/**", - "categories.xml", - "entries2html.xsl", - "notes.xsl" - ] - }, - "build-posts": { - page: "pages/**" - }, - "build-xml-entries": { - all: "entries/**" - }, - "build-resources": { - all: "resources/**" - }, - wordpress: (function() { - var config = require( "./config" ); - config.dir = "dist/wordpress"; - return config; - })() -}); - -grunt.registerTask( "lint", [ "xmllint" ] ); - -grunt.registerTask( "build", [ - "build-posts", - "build-resources", - "build-xml-entries", - "build-xml-categories", - "build-xml-full" -]); - -}; diff --git a/README.md b/README.md index 9b756c0..40d8bb7 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,8 @@ To test the site locally: - `documentation.md` - API documentation - `contribute.md` - Contribution guide - `reference.md` - General guidelines and reference -- `entries/` - XML documentation entries (for API methods) -- `pages/` - Original content files (kept for reference) +- `_entries/` - Markdown documentation entries (for API methods, converted from XML) +- `_layouts/` - Jekyll layout templates ### Deployment diff --git a/_config.yml b/_config.yml index 838a620..f6ac7ba 100644 --- a/_config.yml +++ b/_config.yml @@ -8,14 +8,8 @@ markdown: kramdown # Exclude from processing exclude: - - Gruntfile.js - - package.json - - package-lock.json - node_modules - config.json - - config-sample.json - - entries2html.xsl - - notes.xsl - README.md - LICENSE-MIT.txt - .gitignore @@ -24,8 +18,6 @@ exclude: - Gemfile - Gemfile.lock - GITHUB_PAGES_SETUP.md - - entries - - convert_entries.py - CONVERSION_NOTES.md # Collections diff --git a/categories.xml b/categories.xml deleted file mode 100644 index 0ee3c94..0000000 --- a/categories.xml +++ /dev/null @@ -1,16 +0,0 @@ -<categories> - <category name="Uncategorized" slug="uncategorized"/> - <category name="Methods" slug="methods"></category> - <category name="Additional Methods" slug="additional-methods"></category> - <category name="Plugin Methods" slug="plugin"> - <desc><![CDATA[ - All jQuery methods that the plugin adds, available on all jQuery objects. - ]]></desc> - </category> - <category name="Validator" slug="validator"> - <desc><![CDATA[ - Methods available on the Validator object returned by the validate method. - ]]></desc> - </category> - <category name="Selectors" slug="selectors"/> -</categories> diff --git a/config-sample.json b/config-sample.json deleted file mode 100644 index fc44401..0000000 --- a/config-sample.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "url": "https://jqueryvalidation.org/", - "username": "admin", - "password": "secret", - "basicAuth": { - "username": "basic-auth-admin", - "password": "basic-auth-secret" - } -} diff --git a/convert_entries.py b/convert_entries.py deleted file mode 100644 index 8021c83..0000000 --- a/convert_entries.py +++ /dev/null @@ -1,296 +0,0 @@ -#!/usr/bin/env python3 -""" -Convert XML entry files to Markdown format for Jekyll. -""" - -import os -import re -import xml.etree.ElementTree as ET -from pathlib import Path - - -def clean_text(text): - """Clean and normalize text content.""" - if not text: - return "" - # Remove excessive whitespace - text = re.sub(r'\s+', ' ', text.strip()) - return text - - -def convert_html_entities(text): - """Convert common HTML entities.""" - if not text: - return "" - text = text.replace('<', '<') - text = text.replace('>', '>') - text = text.replace('&', '&') - text = text.replace('"', '"') - return text - - -def extract_text_with_html(elem): - """Extract text and HTML content from an element, preserving structure.""" - if elem is None: - return "" - - # Get all text including from children - parts = [] - if elem.text: - parts.append(elem.text) - - for child in elem: - # Handle special elements - if child.tag == 'code': - code_text = ''.join(child.itertext()) - parts.append(f'`{code_text}`') - elif child.tag == 'p': - p_text = extract_text_with_html(child) - parts.append(f'\n\n{p_text}') - elif child.tag == 'a': - link_text = ''.join(child.itertext()) - href = child.get('href', '') - parts.append(f'[{link_text}]({href})') - else: - parts.append(''.join(child.itertext())) - - if child.tail: - parts.append(child.tail) - - return ''.join(parts) - - -def parse_signature(sig_elem): - """Parse a signature element and return markdown.""" - lines = [] - - # Get description if present - desc_elem = sig_elem.find('desc') - if desc_elem is not None: - desc_text = extract_text_with_html(desc_elem) - if desc_text: - lines.append(clean_text(desc_text)) - lines.append("") - - # Get arguments - for arg in sig_elem.findall('argument'): - arg_name = arg.get('name', 'argument') - arg_type = arg.get('type', 'Any') - optional = arg.get('optional', 'false') == 'true' - default_val = arg.get('default', '') - - arg_desc_elem = arg.find('desc') - arg_desc = "" - if arg_desc_elem is not None: - arg_desc = extract_text_with_html(arg_desc_elem) - - opt_str = " (optional)" if optional else "" - default_str = f" (default: `{default_val}`)" if default_val else "" - lines.append(f"**{arg_name}** *({arg_type})*{opt_str}{default_str}") - if arg_desc: - lines.append("") - lines.append(clean_text(arg_desc)) - lines.append("") - - # Handle nested properties (recursively) - parse_properties(arg, lines, indent=1) - - return '\n'.join(lines) - - -def parse_properties(parent_elem, lines, indent=0): - """Recursively parse property elements.""" - for prop in parent_elem.findall('property'): - prop_name = prop.get('name', 'property') - prop_type = prop.get('type', 'Any') - default_val = prop.get('default', '') - - prop_desc_elem = prop.find('desc') - prop_desc = "" - if prop_desc_elem is not None: - prop_desc = extract_text_with_html(prop_desc_elem) - - indent_str = " " * indent - default_str = f" (default: `{default_val}`)" if default_val else "" - - # Format the property line - lines.append(f"{indent_str}**{prop_name}** *({prop_type})*{default_str}") - if prop_desc: - lines.append("") - # Indent description text - desc_lines = clean_text(prop_desc).split('\n') - for desc_line in desc_lines: - if desc_line.strip(): - lines.append(f"{indent_str}{desc_line}") - lines.append("") - - # Recursively handle nested properties - nested_props = prop.findall('property') - if nested_props: - parse_properties(prop, lines, indent + 1) - - -def parse_example(example_elem): - """Parse an example element and return markdown.""" - lines = [] - - # Get description - desc_elem = example_elem.find('desc') - if desc_elem is not None: - desc_text = extract_text_with_html(desc_elem) - if desc_text: - lines.append(clean_text(desc_text)) - lines.append("") - - # Get code - code_elem = example_elem.find('code') - if code_elem is not None: - code_text = code_elem.text or "" - # Handle CDATA - if code_text: - lines.append("```javascript") - lines.append(code_text.strip()) - lines.append("```") - lines.append("") - - # Get HTML - html_elem = example_elem.find('html') - if html_elem is not None: - html_text = html_elem.text or "" - if html_text: - lines.append("```html") - lines.append(html_text.strip()) - lines.append("```") - lines.append("") - - return '\n'.join(lines) - - -def convert_xml_to_markdown(xml_path): - """Convert an XML entry file to Markdown format.""" - tree = ET.parse(xml_path) - root = tree.getroot() - - # Extract metadata - entry_name = root.get('name', '') - entry_type = root.get('type', 'method') - return_type = root.get('return', '') - - # Extract title - title_elem = root.find('title') - title = title_elem.text if title_elem is not None else entry_name - - # Extract description - desc_elem = root.find('desc') - desc = extract_text_with_html(desc_elem) if desc_elem is not None else "" - - # Extract long description - longdesc_elem = root.find('longdesc') - longdesc = extract_text_with_html(longdesc_elem) if longdesc_elem is not None else "" - - # Extract sample (for selectors) - sample_elem = root.find('sample') - sample = sample_elem.text if sample_elem is not None else "" - - # Extract category - category_elem = root.find('category') - category = category_elem.get('slug', 'methods') if category_elem is not None else 'methods' - - # Start building markdown - lines = [] - - # Front matter - lines.append("---") - lines.append(f"title: {title}") - lines.append(f"entry_name: {entry_name}") - lines.append(f"entry_type: {entry_type}") - if return_type: - lines.append(f"return_type: {return_type}") - lines.append(f"category: {category}") - lines.append("layout: default") - lines.append("---") - lines.append("") - - # Title - lines.append(f"# {title}") - lines.append("") - - # Sample (for selectors) - if sample: - lines.append(f"**Selector:** `{sample}`") - lines.append("") - - # Description - if desc: - lines.append(clean_text(desc)) - lines.append("") - - # Long description - if longdesc: - lines.append("## Description") - lines.append("") - lines.append(clean_text(longdesc)) - lines.append("") - - # Signatures - signatures = root.findall('signature') - if signatures: - if len(signatures) == 1: - lines.append("## Usage") - lines.append("") - lines.append(parse_signature(signatures[0])) - else: - lines.append("## Usage") - lines.append("") - for i, sig in enumerate(signatures, 1): - if len(signatures) > 1: - lines.append(f"### Form {i}") - lines.append("") - lines.append(parse_signature(sig)) - - # Examples - examples = root.findall('example') - if examples: - lines.append("## Examples") - lines.append("") - for i, example in enumerate(examples, 1): - if len(examples) > 1: - lines.append(f"### Example {i}") - lines.append("") - lines.append(parse_example(example)) - - return '\n'.join(lines) - - -def main(): - """Main conversion function.""" - script_dir = Path(__file__).parent - entries_dir = script_dir / 'entries' - output_dir = script_dir / '_entries' - - # Create output directory - output_dir.mkdir(exist_ok=True) - - # Convert each XML file - xml_files = sorted(entries_dir.glob('*.xml')) - print(f"Found {len(xml_files)} XML files to convert") - - for xml_file in xml_files: - print(f"Converting {xml_file.name}...") - try: - markdown_content = convert_xml_to_markdown(xml_file) - - # Create output filename - output_file = output_dir / xml_file.with_suffix('.md').name - - # Write markdown file - output_file.write_text(markdown_content) - print(f" -> {output_file.name}") - except Exception as e: - print(f" ERROR: {e}") - - print(f"\nConversion complete! {len(xml_files)} files converted to {output_dir}") - - -if __name__ == '__main__': - main() diff --git a/entries/Validator.destroy.xml b/entries/Validator.destroy.xml deleted file mode 100644 index 89c9714..0000000 --- a/entries/Validator.destroy.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?> -<entry type="method" name="Validator.destroy"> - <title>Validator.destroy() - - - Destroys this instance of validator freeing up resources and unregistering events. - This is only useful, when you need to clean up after the validator in a Single Page Application. - - Destroying an instance of validator. - - - - diff --git a/entries/Validator.element.xml b/entries/Validator.element.xml deleted file mode 100644 index 1a07f94..0000000 --- a/entries/Validator.element.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - Validator.element() - - - An element to validate, must be inside the validated form. - - - Validates a single element, returns true if it is valid, false otherwise. - This behaves as validation on blur or keyup, but returns the result. - - Triggers element validation programmatically. - - - - diff --git a/entries/Validator.form.xml b/entries/Validator.form.xml deleted file mode 100644 index 4868ee4..0000000 --- a/entries/Validator.form.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Validator.form() - - - Validates the form, returns true if it is valid, false otherwise. - This behaves as a normal submit event, but returns the result. - - Triggers form validation programmatically. - - - - diff --git a/entries/Validator.numberOfInvalids.xml b/entries/Validator.numberOfInvalids.xml deleted file mode 100644 index afc6df0..0000000 --- a/entries/Validator.numberOfInvalids.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - Validator.numberOfInvalids() - - - One or more key/value pairs of input names and messages. - - - Returns the number of invalid fields. - This depends on the internal validator state. It covers all fields only after validating the complete form (on submit or via $("form").valid()). After validating a single element, only that element is counted. Most useful in combination with the invalidHandler-option. - - Displays a summary of invalid fields after an invalid submit. - - - - diff --git a/entries/Validator.resetForm.xml b/entries/Validator.resetForm.xml deleted file mode 100644 index c836760..0000000 --- a/entries/Validator.resetForm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Validator.resetForm() - - - Resets the controlled form. - Resets input fields to their original value (requires form plugin), removes classes indicating invalid elements and hides error messages. - - Reset the form controlled by this validator. - - - - diff --git a/entries/Validator.showErrors.xml b/entries/Validator.showErrors.xml deleted file mode 100644 index fed646f..0000000 --- a/entries/Validator.showErrors.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - Validator.showErrors() - - - One or more key/value pairs of input names and messages. - - - Show the specified messages. - Keys have to refer to the names of elements, values are displayed for those elements, using the configured error placement. - - Adds and shows error message programmatically. - - - - diff --git a/entries/accept-method.xml b/entries/accept-method.xml deleted file mode 100644 index 529c1a0..0000000 --- a/entries/accept-method.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - accept method - Makes a file upload accept only specified mime-types. - - Uses the HTML5 file API to look at the type attribute of one or more selected files and validate that each matches the specified mime-type. - -

If nothing is specified, only images are allowed (image/*).

- -

You can specify multiple mime-types by separating them with a comma, e.g. "image/x-eps,application/pdf".

- -

Works with type="file" inputs.

-

Part of the additional-methods.js file

-

Note: This method used to look at just the filename, specifically the file extension. That behaviour is now available as the "extension" method inside src/additional/extension.js.

-
- - - - The allowed type, seperated via ",", defaults to "image/*" - - - - - Required, only audio files allowed: - -Required, audio files only: - -
- -]]> -
- -
diff --git a/entries/blank-selector.xml b/entries/blank-selector.xml deleted file mode 100644 index e62284d..0000000 --- a/entries/blank-selector.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - :blank Selector - :blank - - - Selects all elements with a blank value. - - Blank means either no value at all or only whitespace. -

The implementation does a check like this: jQuery.trim(value).length == 0

-
- - Finds input elements with no value or just whitespace. - - Mouseover to see the value of each input - - - -]]> - - -
\ No newline at end of file diff --git a/entries/creditcard-method.xml b/entries/creditcard-method.xml deleted file mode 100644 index 14a18f5..0000000 --- a/entries/creditcard-method.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - creditcard method - Makes the element require a credit card number. - - Return true if the value is a valid credit card number. -

Works with text inputs.

-

Part of the additional-methods.js file

-

Note: The algorithm used can't verify the validity of the number - it is just an integrity check. As with any other clientside validation, you have to implement the same or better validation on the serverside.

-
- - Makes "field" required and credit card only. - -Required, creditcard (try 446-667-651): - -
- -]]> -
- -
diff --git a/entries/date-method.xml b/entries/date-method.xml deleted file mode 100644 index 4d2285b..0000000 --- a/entries/date-method.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - [DEPRECATED] date method - Makes the element require a date. - - Return true if the value is a valid date. Uses JavaScript's built-in Date to test if the date is valid, and therefore does no sanity checks. Only the format must be valid, not the actual date, eg 30/30/2008 is a valid date. -

DEPRECATION warning:

-

This method is deprecated and will be removed in version 2.0.0.
Please don't use it, since it relies on the Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

-
- - Makes "field" required and a date. - -Required, date: - -
- -]]> -
- -
diff --git a/entries/dateISO-method.xml b/entries/dateISO-method.xml deleted file mode 100644 index a7b7355..0000000 --- a/entries/dateISO-method.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - dateISO method - Makes the element require an ISO date. - - Return true if the value is a valid date according to ISO date standard. -

Works with text inputs.

-
- - Makes "field" required and an ISO date. - -Required, dateISO: - -
- -]]> -
- -
diff --git a/entries/digits-method.xml b/entries/digits-method.xml deleted file mode 100644 index f88261b..0000000 --- a/entries/digits-method.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - digits method - Makes the element require digits only. - - Returns true if the value contains only digits. -

Works with text inputs.

-
- - Makes "field" required and digits only. - -Required, digits: - -
- -]]> -
- -
diff --git a/entries/email-method.xml b/entries/email-method.xml deleted file mode 100644 index b0ba4e9..0000000 --- a/entries/email-method.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - email method - Makes the element require a valid email - - Return true if the value is a valid email address. -

Works with text inputs.

-

IMPORTANT NOTE:

-

As of version 1.12.0 we started using the same regular expression that the HTML5 specification suggests for browsers to use. We will follow their lead and use the same check. In case you need to adjust the built-in validation regular expression patterns, please use the $.validator.methods property. If you have different requirements, please consider using a custom method.

-
- - Makes "field" required and an email address. - -Required, email: - -
- -]]> -
- -
diff --git a/entries/equalTo-method.xml b/entries/equalTo-method.xml deleted file mode 100644 index 6317b55..0000000 --- a/entries/equalTo-method.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - equalTo method - Requires the element to be the same as another one - - Returns true if the value has the same value as the element specified by the first parameter. - - - - - The selector for the element to compare the current values - - - - - Makes "field" required to be the same as #other - -Password - -
- - -
- -]]> -
- -
diff --git a/entries/extension-method.xml b/entries/extension-method.xml deleted file mode 100644 index 0e8ec9a..0000000 --- a/entries/extension-method.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - extension method - Makes the element require a certain file extension. - - Returns true if the value ends with one of the specified file extensions. If nothing is specified, only images are allowed (png, jpeg, gif). -

Works with text inputs.

-

Part of the additional-methods.js file

-
- - - - The allowed file extensions, seperated with "|" (or a comma, ","), defaults to "png|jpe?g|gif". - - - - - Makes "field" required and ending with ".xls" or ".csv". - -Required, only .xls and .csv files allowed: - -
- -]]> -
- -
diff --git a/entries/filled-selector.xml b/entries/filled-selector.xml deleted file mode 100644 index 2c282a8..0000000 --- a/entries/filled-selector.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - :filled Selector - :filled - - - Selects all elements with a filled value. - - filled means any value, but not only whitespace. -

The implementation does a check like this: jQuery.trim(value).length > 0

-
- - Finds input elements with a non-whitespace value. - - Mouseover to see the value of each input - - - -]]> - - -
\ No newline at end of file diff --git a/entries/jQuery.validator.addClassRules.xml b/entries/jQuery.validator.addClassRules.xml deleted file mode 100644 index a26efa9..0000000 --- a/entries/jQuery.validator.addClassRules.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - jQuery.validator.addClassRules() - - - The name of the class rule to add - - - The compound rules (see example) - - - - - A map of className-rules pairs (see example). - - - Add a compound class method - useful to refactor common combinations of rules into a single class. - - Add a new compound rule called "name", replacing class="required" minlength="2" with class="name". - - - - Add two compound class rules for name and zip. - - - - diff --git a/entries/jQuery.validator.addMethod.xml b/entries/jQuery.validator.addMethod.xml deleted file mode 100644 index 59d3fa5..0000000 --- a/entries/jQuery.validator.addMethod.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - jQuery.validator.addMethod() - - - The name of the method used to identify it and referencing it; this must be a valid JavaScript identifier - - - The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters. - - the current value of the validated element - - - the element to be validated - - - parameters specified for the method, e.g. for min: 5, the parameter is 5, for range: [1, 5] it's [1, 5] - - - - The default message to display for this method. Can be a function created by ''jQuery.validator.format(value)''. When undefined, an existing message is used (handy for localization), otherwise the field-specific messages have to be defined. - - - Add a custom validation method. It must consist of a name (must be a legal javascript identifier), a javascript based function and a default string message. - -For simple one-off validation, you can use the bundled pattern method (in additional methods, source in src/additional/pattern.js) to validate a field against a regular expression. In general, it is a good idea to encapsulate those regular expressions inside their own method. If you need lots of slightly different expressions, try to extract a common parameter. - -See also a library of regular expressions. - - - Add a validation method that checks if a value starts with a certain domain. - - - - Adds a validation method that checks if a given value equals the addition of the two parameters. - - - - Adds a custom email validation method that is less strict than the one built-in. - - - - diff --git a/entries/jQuery.validator.format.xml b/entries/jQuery.validator.format.xml deleted file mode 100644 index 49c63c5..0000000 --- a/entries/jQuery.validator.format.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - jQuery.validator.format() - - - The string to format. - - - The first argument to insert, or an array of Strings to insert - - - The second etc. argument to insert - - - Replaces {n} placeholders with arguments. - - One or more arguments can be passed, in addition to the string template itself, to insert into the string. -

If you're familiar with the term, this makes this function support currying. If you don't care about that, just use the first argument.

-
- - Sets the debug setting for all validation calls. - - - -
diff --git a/entries/jQuery.validator.methods.xml b/entries/jQuery.validator.methods.xml deleted file mode 100644 index eba2d32..0000000 --- a/entries/jQuery.validator.methods.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - jQuery.validator.methods - Object holding all validation methods known to the validator. This can be accessed to override individual methods, while keeping the default messages. - - Sets a custom email pattern for the built-in email validation rule. - - - - diff --git a/entries/jQuery.validator.setDefaults.xml b/entries/jQuery.validator.setDefaults.xml deleted file mode 100644 index 7a5c7e8..0000000 --- a/entries/jQuery.validator.setDefaults.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - jQuery.validator.setDefaults() - - - Options to set as default. - - - Modify default settings for validation. - Accepts everything that validate() accepts. - - Sets the debug setting for all validation calls. - - - - diff --git a/entries/max-method.xml b/entries/max-method.xml deleted file mode 100644 index 41a947f..0000000 --- a/entries/max-method.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - max method - Makes the element require a given maximum. - - Works with text inputs. To exclude the maximum value, subtract Number.MIN_VALUE from that value. - - - - - Maximum value required - - - - - Makes "field" required and 23 or smaller. - -Required, maximum value 23: - -
- -]]> -
- -
diff --git a/entries/maxlength-method.xml b/entries/maxlength-method.xml deleted file mode 100644 index 2497acd..0000000 --- a/entries/maxlength-method.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - maxlength method - Makes the element require a given maximum length. - - Return false if the element is -
    -
  • some kind of text input and its value is too long
  • -
  • a set of checkboxes that has too many boxes checked
  • -
  • a select and has too many options selected
  • -
-

Works with text inputs, selects and checkboxes.

-
- - - - Maximum number of characters required - - - - - Makes "field" required having at most 4 characters. - -Required, maximum length 4: - -
- -]]> -
- -
diff --git a/entries/min-method.xml b/entries/min-method.xml deleted file mode 100644 index de7e1d0..0000000 --- a/entries/min-method.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - min method - Makes the element require a given minimum. - - Works with text inputs. To exclude the minimum value, add Number.MIN_VALUE to that value. - - - - - Minimum value required - - - - - Makes "field" required and 13 or larger. - -Required, minimum 13: - -
- -]]> -
- -
diff --git a/entries/minlength-method.xml b/entries/minlength-method.xml deleted file mode 100644 index ade78e5..0000000 --- a/entries/minlength-method.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - minlength method - Makes the element require a given minimum length. - - Return false if the element is -
    -
  • some kind of text input and its value is too short
  • -
  • a set of checkboxes that doesn't have enough boxes checked
  • -
  • a select and doesn't have enough options selected
  • -
-

Works with text inputs, selects and checkboxes.

-
- - - - Minimum number of characters required - - - - - Makes "field" required having at least 3 characters. - -Required, minimum length 3: - -
- -]]> -
- -
diff --git a/entries/normalizer.xml b/entries/normalizer.xml deleted file mode 100644 index aa13830..0000000 --- a/entries/normalizer.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - normalizer - - - The value of the element. - - - Prepares/transforms the elements value for validation. - -

Transform the value of an element and the result for validation instead of the initial value. The normalizer can be defined global to all elements or local to only one element. With that said, the local normalizer will only run for the element for which it was defined. The global normalizer will run for all validated elements. This normalizer can be then overrided for each element, as needed, by attaching one to it. This way only the local one will run for that element, and the global one will run for others.

-

Note that this method:

-
    -
  • Has been available since version 1.15.0

  • -
  • Doesn't change the elements' value, it only changes the value used for validation.

  • -
  • Gets the value passed as argument, and "this" within it references the corresponding DOMElement.

  • -
  • For versions between 1.15.0 and 1.17.0, it must return a string value. And as of 1.17.1, it can return any value including null and undefined.

  • -
-
- - Makes "field" required and use a normalizer to trim its value before validating - -Required: - -
- -]]> -
- - Makes "url" required and use a normalizer to append 'http://', if not present, to the value of the "url" element before validating - -url: - -
- -]]> -
- - - Using a global normalizer in conjunction with a local one - -Required: - -
- - -
- -]]> -
- -
diff --git a/entries/number-method.xml b/entries/number-method.xml deleted file mode 100644 index 75f8a25..0000000 --- a/entries/number-method.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - number method - Makes the element require a decimal number. - - Returns true if the value contains a valid decimal number. -

Works with text inputs.

-
- - Makes "field" required and a decimal number only. - -Required, decimal number: - -
- -]]> -
- -
diff --git a/entries/phoneUS-method.xml b/entries/phoneUS-method.xml deleted file mode 100644 index 3490c7e..0000000 --- a/entries/phoneUS-method.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - phoneUS method - Validate for valid US phone number. - - Works with text inputs. -

Part of the additional-methods.js file

-
- - Makes "field" required and a US phone number. - -Required, us phone number: - -
- -]]> -
- -
diff --git a/entries/range-method.xml b/entries/range-method.xml deleted file mode 100644 index e050277..0000000 --- a/entries/range-method.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - range method - Makes the element require a given value range. - - Works with text inputs. To exclude the maximum value, subtract Number.MIN_VALUE from that value. To exclude the minimum value, add Number.MIN_VALUE to that value. - - - - - Value range required - - - - - Makes "field" required and between 13 and 23. - -Required, minimum 13, maximum 23: - -
- -]]> -
- -
diff --git a/entries/rangelength-method.xml b/entries/rangelength-method.xml deleted file mode 100644 index 4bde3e2..0000000 --- a/entries/rangelength-method.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - rangelength method - Makes the element require a given value range. - - Return false if the element is -
    -
  • some kind of text input and its length is too short or too long
  • -
  • a set of checkboxes that doesn't have enough, or has too many boxes checked
  • -
  • a select that doesn't have enough, or has too many options selected
  • -
-

Works with text inputs, selects and checkboxes.

-
- - - - Value range required - - - - - Makes "field" required and between 2 and 6 characters long. - -Required, minimum length 2, maximum length 6: - -
- -]]> -
- -
diff --git a/entries/remote-method.xml b/entries/remote-method.xml deleted file mode 100644 index 8ed7288..0000000 --- a/entries/remote-method.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - remote method - Requests a resource to check the element for validity. - - The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a key/value pair corresponding to the name of the validated element and its value as a GET parameter. The serverside response must be a JSON string that must be "true" for valid elements, and can be "false", undefined, or null for invalid elements, using the default error message. If the serverside response is a string, eg. "That name is already taken, try peter123 instead", this string will be displayed as a custom error message in place of the default. - -

For more examples, take a look the marketo demo and the milk demo.

-
- - - - For the URL of the resource to request for serverside validation (String) or options to fully customize the request, see jQuery.ajax for details. -

These options deep-extend the defaults (dataType:"json", data:{nameOfTheElement:valueOfTheElement}). Any options you provide will override the defaults.

-
-
-
- - Makes the email field required, an email and does a remote request to check if the given address is already taken. - - - - Makes the email field required, an email and does a remote request to check if the given address is already taken. In addition, the http method is set to "post" and the username is sent alongside the email address. - - - -
diff --git a/entries/require_from_group-method.xml b/entries/require_from_group-method.xml deleted file mode 100644 index b389026..0000000 --- a/entries/require_from_group-method.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - require_from_group method - Ensures a given number of fields in a group are complete. - - In the options passed to the rule, supply the minimum number of fields - within the group that must be complete and a selector to define the - group. Then apply this rule to all the fields within the group. - The form then cannot be submitted until at least the minimum number have - been completed. -

Part of the additional-methods.js file

-
- - Within a group of three phone numbers, ensure at least one is complete. - -Mobile phone: - -
- - -
- - -
- -]]> -
- -
diff --git a/entries/required-method.xml b/entries/required-method.xml deleted file mode 100644 index 755d1aa..0000000 --- a/entries/required-method.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - required method - Makes the element required. - - Return false, if the element is empty (text input) or unchecked (radio/checkbox) or if nothing is selected (select). -

Works with text inputs, selects, checkboxes and radio buttons.

-

To force a user to select an option from a select box, provide an empty option element like <option value="">Choose...</option>

-

Note that white spaces are considered valid.

-
- - The element is always required. - - - Makes the element required, depending on the result of the given expression. - - - An expression (String) that is evaluated in the context of the element's form, making the field required only if the expression returns more than one element. -

Very often your expression will use selector filters such as #foo:checked, #foo:filled, #foo:visible. This plugin provides custom selectors for that purpose.

-
-
-
- - Makes the element required, depending on the result of the given callback. - - - The function is executed with the element as it's only argument: If it returns true, the element is required. - - - - - Makes "field" always required. - -Required: - -
- -]]> -
- - Makes the fruit select required. - -Please select a fruit - -
- -]]> -
- - Makes the gender radio buttons required. - - - - Male - - - -
- -]]> -
- - Makes the agree checkbox required. - -Please agree to our policy - -
- -]]> -
- - Makes details required only if #other is checked. - -Check to make next field required - -
- -
- -]]> -
- - Makes "parent" required only if age is below 13. - -Age - -
- - -
- -]]> -
- -
diff --git a/entries/rules.xml b/entries/rules.xml deleted file mode 100644 index 5c510bc..0000000 --- a/entries/rules.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - .rules() - Read, add and remove rules for an element. - - Returns the validations rules for the first selected element or - -

Adds the specified rules and returns all rules for the first matched element. Requires that the parent form is validated, that is, $( "form" ).validate() is called first or

- -

Removes the specified rules and returns all rules for the first matched element.

- -

There are several ways to specify validation rules.

-
    -
  • Validation methods with parameters can be specified as attributes (recommended)
  • -
  • Validation methods without parameters can be specified as classes on the element
  • -
  • Both can be specified using the rules-option of the validate()-method
  • -
  • Both rules and messages can be specified using data attributes, using data-msg (a generic, not-method specific message), data-msg-[method] and data-rule-[method].
  • -
-

When setting, the rules can also contain a messages-object, specifying custom messages for existing or added rules.

-
- - Read rules for the first element - - - Add rules - - - The rules to add. Accepts the same format as the rules-option of the validate-method. - - - - Remove rules - - - The space-seperated names of rules to remove and return. If left unspecified, removes and returns all rules. Manipulates only rules specified via rules-option or via rules("add"). - - - - Adds minlength: 2 to an element which is already required. - - - - Adds required and minlength: 2 to an element and specifies custom messages for both. - - - - Removes all static rules from an element. - - - - Removes min and max rules from an element. - - - -
diff --git a/entries/step-method.xml b/entries/step-method.xml deleted file mode 100644 index 5202f29..0000000 --- a/entries/step-method.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - step method - Makes the element require a given step. - - Works with text inputs. No support for input types: date, datetime, datetime-local, month, time and week. - - - - - Step value required - - - - - Makes "field" required and step of 10. - -Required, step 10: - -
- -]]> -
- -
diff --git a/entries/unchecked-selector.xml b/entries/unchecked-selector.xml deleted file mode 100644 index 427918a..0000000 --- a/entries/unchecked-selector.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - :unchecked Selector - :unchecked - - - Selects all elements that are unchecked. - - Inversion of :checked. - - - Finds all input elements that are unchecked. - - - - - - - - - - - -
-]]> -
- -
diff --git a/entries/url-method.xml b/entries/url-method.xml deleted file mode 100644 index 3bf8df7..0000000 --- a/entries/url-method.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - url method - Makes the element require a valid url - - Return true, if the value is a valid url. -

Works with text inputs.

-
- - Makes "field" required and a url. - -Required, URL: - -
- -]]> -
- -
diff --git a/entries/valid.xml b/entries/valid.xml deleted file mode 100644 index feb79ea..0000000 --- a/entries/valid.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - .valid() - Checks whether the selected form is valid or whether all selected elements are valid. - - validate() needs to be called on the form before checking it using this method. - - - - - Sets up validation for a form, then checks if the form is valid when clicking a button. - - - - -
- - -]]> -
- -
diff --git a/entries/validate.xml b/entries/validate.xml deleted file mode 100644 index 640ed6c..0000000 --- a/entries/validate.xml +++ /dev/null @@ -1,544 +0,0 @@ - - - .validate() - Validates the selected form. - - This method sets up event handlers for submit, focus, keyup, blur and click to trigger validation of the entire form or individual elements. Each one can be disabled, see the onxxx options (onsubmit, onfocusout, onkeyup, onclick). focusInvalid focuses elements when submitting an invalid form. -

Use the debug option to ease setting up validation rules, it always prevents the default submit, even when script errors occur.

-

Use submitHandler to implement your own form submit, eg. via Ajax. Use invalidHandler to react when an invalid form is submitted.

-

Use rules and messages to specify which elements to validate, and how. See rules() for more details about specifying validation rules.

-

Use errorClass, errorElement, wrapper, errorLabelContainer, errorContainer, showErrors, success, errorPlacement, highlight, unhighlight, and ignoreTitle to control how invalid elements and error messages are displayed.

-
- - - - - Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a window.console property exists). Try to enable when a form is just submitted instead of validation stopping the submit. -

Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages.

-

-					$("#myform").validate({
-						debug: true
-					});
-					
-
- -
- - - Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. -

Example: Submits the form via Ajax, using jQuery Form plugin, when valid.

-

-					$("#myform").validate({
-						submitHandler: function(form) {
-							$(form).ajaxSubmit();
-						}
-					});
-					
-

Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again.

-

-					$("#myform").validate({
-						submitHandler: function(form) {
-							// do other things for a valid form
-							form.submit();
-						}
-					});
-					
-

The callback gets passed two arguments:

-
- - The form currently being validated, as a DOMElement. - - - The submit event instance. - - -
- - - Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. -

Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form.

-

-					$("#myform").validate({
-						invalidHandler: function(event, validator) {
-							// 'this' refers to the form
-							var errors = validator.numberOfInvalids();
-							if (errors) {
-								var message = errors == 1
-									? 'You missed 1 field. It has been highlighted'
-									: 'You missed ' + errors + ' fields. They have been highlighted';
-								$("div.error span").html(message);
-								$("div.error").show();
-							} else {
-								$("div.error").hide();
-							}
-						}
-					});
-					
-

The callback gets passed two arguments:

-
- - A custom event object, since this function is bound as an event handler. - - - The validator instance for the current form. - - -
- - - Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. -

Example: Ignores all elements with the class "ignore" when validating.

-

-					$("#myform").validate({
-						ignore: ".ignore"
-					});
-					
-
- -
- - - Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. -

Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal).

-

-					$("#myform").validate({
-						rules: {
-							// simple rule, converted to {required:true}
-							name: "required",
-							// compound rule
-							email: {
-								required: true,
-								email: true
-							}
-						}
-					});
-					
-

Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email.

-

-					$("#myform").validate({
-						rules: {
-							contact: {
-								required: true,
-								email: {
-									depends: function(element) {
-										return $("#contactform_email").is(":checked");
-									}
-								}
-							}
-						}
-					});
-					
-

Example: Configure a rule that requires a parameter, along with a depends callback.

-

-					$("#myform").validate({
-						rules: {
-							// at least 15€ when bonus material is included
-							pay_what_you_want: {
-								required: true
-								min: {
-									// min needs a parameter passed to it
-									param: 15,
-									depends: function(element) {
-										return $("#bonus-material").is(":checked");
-									}
-								}
-							}
-						}
-					});
-					
-
- -
- - - Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. -

Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email.

-

-					$("#myform").validate({
-						rules: {
-							name: "required",
-							email: {
-								required: true,
-								email: true
-							}
-						},
-						messages: {
-							name: "Please specify your name",
-							email: {
-								required: "We need your email address to contact you",
-								email: "Your email address must be in the format of name@domain.com"
-							}
-						}
-					});
-					
-

Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places.

-

-					$("#myform").validate({
-						rules: {
-							name: {
-								required: true,
-								minlength: 2
-							}
-						},
-						messages: {
-							name: {
-								required: "We need your email address to contact you",
-								minlength: jQuery.validator.format("At least {0} characters required!")
-							}
-						}
-					});
-					
-
- -
- - - Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. -

Example: Use a table layout for the form, placing error messags in the next cell after the input.

-

-					$("#myform").validate({
-						groups: {
-							username: "fname lname"
-						},
-						errorPlacement: function(error, element) {
-							if (element.attr("name") == "fname" || element.attr("name") == "lname" ) {
-								error.insertAfter("#lastname");
-							} else {
-								error.insertAfter(element);
-							}
-						}
-					});
-					
-
- -
- - - Prepares/transforms the elements value for validation. - See normalizer docs for more details. - - - - - - Validate the form on submit. Set to false to use only other events for validation. -

Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise).

-

-					$("#myform").validate({
-						onsubmit: false
-					});
-					
-
- -
- - - Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. -

Set to a Function to decide for yourself when to run validation.

-

A boolean true is not a valid value.

-

Example: Disables focusout validation.

-

-					$("#myform").validate({
-						onfocusout: false
-					});
-					
-

The callback gets passed two arguments:

-
- - The element currently being validated, as a DOMElement. - - - The event object for this focusout event. - - - -
- - - Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. -

Set to a Function to decide for yourself when to run validation.

-

A boolean true is not a valid value.

-

Example: Disables onkeyup validation.

-

-					$("#myform").validate({
-						onkeyup: false
-					});
-					
-

The callback gets passed two arguments:

-
- - The element currently being validated, as a DOMElement. - - - The event object for this keyup event. - - - -
- - - Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. -

Set to a Function to decide for yourself when to run validation.

-

A boolean true is not a valid value.

-

Example: Disables onclick validation of checkboxes, radio buttons, and select elements.

-

-					$("#myform").validate({
-						onclick: false
-					});
-					
-

The callback gets passed two arguments:

-
- - The element currently being validated, as a DOMElement. - - - The event object for this click event. - - - -
- - - Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. -

Example: Disables focusing of invalid elements.

-

-					$("#myform").validate({
-						focusInvalid: false
-					});
-					
-
- -
- - - If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. -

Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused.

-

-					$("#myform").validate({
-						focusCleanup: true
-					});
-					
-
- -
- - - Use this class to create error labels, to look for existing error labels and to add it to invalid elements. -

Example: Sets the error class to "invalid".

-

-					$("#myform").validate({
-						errorClass: "invalid"
-					});
-					
-
- -
- - - This class is added to an element after it was validated and considered valid. -

Example: Sets the valid class to "success".

-

-					$("#myform").validate({
-						validClass: "success"
-					});
-					
-
- -
- - - Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). -

Example: Sets the error element to "em".

-

-					$("#myform").validate({
-						errorElement: "em"
-					});
-					
-
- -
- - - Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. -

Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container.

-

-					$("#myform").validate({
-						wrapper: "li"
-					});
-					
-
- -
- - - Hide and show this container when validating. -

Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages.

-

-					$("#myform").validate({
-						errorLabelContainer: "#messageBox",
-						wrapper: "li",
-						submitHandler: function() { alert("Submitted!") }
-					});
-					
-
- -
- - - Hide and show this container when validating. -

Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option).

-

-					$("#myform").validate({
-						errorContainer: "#messageBox1, #messageBox2",
-						errorLabelContainer: "#messageBox1 ul",
-						wrapper: "li", debug:true,
-						submitHandler: function() { alert("Submitted!") }
-					});
-					
-
- -
- - - A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). -

Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display.

-

-					$("#myform").validate({
-						showErrors: function(errorMap, errorList) {
-							$("#summary").html("Your form contains "
-								+ this.numberOfInvalids()
-								+ " errors, see details below.");
-							this.defaultShowErrors();
-						}
-					});
-					
-

The callback gets passed two arguments:

-
- - Key/value pairs, where the key refers to the name of an input field, values the message to be displayed for that input. - - - An array for all currently validated elements. Contains objects with the following two properties: - - The message to be displayed for an input. - - - The DOMElement for this entry. - - - -
- - - Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. -

Example: Use a table layout for the form, placing error messages in the next cell after the input.

-

-					$("#myform").validate({
-						errorPlacement: function(error, element) {
-							error.appendTo( element.parent("td").next("td") );
-						}
-					});
-					
-

The callback gets passed two arguments:

-
- - The error label to insert into the DOM. - - - The validated input, for relative positioning. - - -
- - - If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". -

Example: Add a class "valid" to valid elements, styled via CSS.

-

-					$("#myform").validate({
-						success: "valid",
-						submitHandler: function() { alert("Submitted!") }
-					});
-					
-

Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!".

-

-					$("#myform").validate({
-						success: function(label) {
-							label.addClass("valid").text("Ok!")
-						},
-						submitHandler: function() { alert("Submitted!") }
-					});
-					
-

The callback gets passed two arguments:

-
- - The error label. Use to add a class or replace the text content. - - - The element currently being validated, as a DOMElement. - - - -
- - - How to highlight invalid fields. Override to decide which fields and how to highlight. -

Example: Highlights an invalid element by fading it out and in again.

-

-					$("#myform").validate({
-						highlight: function(element, errorClass) {
-							$(element).fadeOut(function() {
-								$(element).fadeIn();
-							});
-						}
-					});
-					
-

Example: Adds the error class to both the invalid element and its label

-

-					$("#myform").validate({
-						highlight: function(element, errorClass, validClass) {
-							$(element).addClass(errorClass).removeClass(validClass);
-							$(element.form).find("label[for=" + element.id + "]")
-								.addClass(errorClass);
-						},
-						unhighlight: function(element, errorClass, validClass) {
-							$(element).removeClass(errorClass).addClass(validClass);
-							$(element.form).find("label[for=" + element.id + "]")
-								.removeClass(errorClass);
-						}
-					});
-					
-

The callback gets passed three arguments:

-
- - - The invalid DOM element, usually an input. - - - Current value of the errorClass option. - - - Current value of the validClass option. - -
- - - Called to revert changes made by option highlight, same arguments as highlight. - - - - - - Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release. -

Example: Configure the plugin to ignore title attributes on validated elements when looking for messages.

-

-					$("#myform").validate({
-						ignoreTitle: true
-					});
-					
-
- -
-
-
- -
diff --git a/entries2html.xsl b/entries2html.xsl deleted file mode 100644 index bcd622d..0000000 --- a/entries2html.xsl +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - -<!doctype html> -<html> -<head> -<meta charset="utf-8"> -<title></title> -<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css"> -<style> </style> -</head> -<body> -<form id="myform"></form> -<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> -<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script> -<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script> -<script> -// just for the demos, avoids form submit -jQuery.validator.setDefaults({ - debug: true, - success: "valid" -});</script> -</body> -</html> - - - diff --git a/notes.xsl b/notes.xsl deleted file mode 100644 index 83ddcee..0000000 --- a/notes.xsl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 8f6eb9e..0000000 --- a/package-lock.json +++ /dev/null @@ -1,733 +0,0 @@ -{ - "name": "jqueryvalidation-content", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "jqueryvalidation-content", - "version": "1.0.0", - "dependencies": { - "grunt": "0.4.5", - "grunt-jquery-content": "2.0.0" - } - }, - "node_modules/abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, - "node_modules/argparse": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", - "integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=", - "dependencies": { - "underscore": "~1.7.0", - "underscore.string": "~2.4.0" - } - }, - "node_modules/argparse/node_modules/underscore.string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", - "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=", - "engines": { - "node": "*" - } - }, - "node_modules/async": { - "version": "0.1.22", - "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", - "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", - "engines": { - "node": "*" - } - }, - "node_modules/cheerio": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.17.0.tgz", - "integrity": "sha1-+lrkLMYBIRM9KW0LRtmDIV9yaOo=", - "dependencies": { - "CSSselect": "~0.4.0", - "dom-serializer": "~0.0.0", - "entities": "~1.1.1", - "htmlparser2": "~3.7.2", - "lodash": "~2.4.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cheerio/node_modules/lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "engines": [ - "node", - "rhino" - ] - }, - "node_modules/coffee-script": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", - "integrity": "sha1-FQ1rTLUiiUNp7+1qIQHCC8f0pPQ=", - "deprecated": "CoffeeScript on NPM has moved to \"coffeescript\" (no hyphen)", - "bin": { - "cake": "bin/cake", - "coffee": "bin/coffee" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/colors": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", - "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", - "engines": { - "node": ">=0.1.90" - } - }, - "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "node_modules/CSSselect": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/CSSselect/-/CSSselect-0.4.1.tgz", - "integrity": "sha1-+Kt+H4QYzmPNput713ioXX7EkrI=", - "deprecated": "the module is now available as 'css-select'", - "dependencies": { - "CSSwhat": "0.4", - "domutils": "1.4" - } - }, - "node_modules/CSSwhat": { - "version": "0.4.7", - "resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz", - "integrity": "sha1-hn2g/zn3eGEyQsRM/qg/CqTr35s=", - "deprecated": "the module is now available as 'css-what'", - "engines": { - "node": "*" - } - }, - "node_modules/dateformat": { - "version": "1.0.2-1.2.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", - "integrity": "sha1-sCIMAt6YYXQztyhRz0fePfLNvuk=", - "engines": { - "node": "*" - } - }, - "node_modules/dom-serializer": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.0.1.tgz", - "integrity": "sha1-lYmCfx4y0iw3yCmtq9WbMkevjq8=", - "dependencies": { - "domelementtype": "~1.1.1", - "entities": "~1.1.1" - } - }, - "node_modules/dom-serializer/node_modules/domelementtype": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=" - }, - "node_modules/domelementtype": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", - "deprecated": "update to domelementtype@1.3.1" - }, - "node_modules/domhandler": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.2.1.tgz", - "integrity": "sha1-Wd+dzSJ+gIs2Wuc+H2aErD2Ub8I=", - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/domutils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.4.3.tgz", - "integrity": "sha1-CGVRN5bGswYDGFDhdVFrr4C3Km8=", - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=" - }, - "node_modules/esprima": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", - "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/eventemitter2": { - "version": "0.4.14", - "resolved": "http://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", - "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=" - }, - "node_modules/exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/findup-sync": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.3.tgz", - "integrity": "sha1-fz56l7gjksZTvwZYm9hRkOk8NoM=", - "dependencies": { - "glob": "~3.2.9", - "lodash": "~2.4.1" - }, - "engines": { - "node": ">= 0.6.0" - } - }, - "node_modules/findup-sync/node_modules/glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "dependencies": { - "inherits": "2", - "minimatch": "0.3" - }, - "engines": { - "node": "*" - } - }, - "node_modules/findup-sync/node_modules/lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "engines": [ - "node", - "rhino" - ] - }, - "node_modules/findup-sync/node_modules/minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", - "deprecated": "Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue", - "dependencies": { - "lru-cache": "2", - "sigmund": "~1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/getobject": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", - "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/gilded-wordpress": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gilded-wordpress/-/gilded-wordpress-1.0.0.tgz", - "integrity": "sha1-xqLn1wetWX2pMQdeAcL+iBtttaA=", - "dependencies": { - "async": "~0.9.0", - "glob": "~4.0.6", - "wordpress": "~1.0.0" - } - }, - "node_modules/gilded-wordpress/node_modules/async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" - }, - "node_modules/gilded-wordpress/node_modules/glob": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.0.6.tgz", - "integrity": "sha1-aVxQvdTi+1xdNwsJHziNNwfikac=", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "dependencies": { - "graceful-fs": "^3.0.2", - "inherits": "2", - "minimatch": "^1.0.0", - "once": "^1.3.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/gilded-wordpress/node_modules/graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "deprecated": "please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js", - "dependencies": { - "natives": "^1.1.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/gilded-wordpress/node_modules/minimatch": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", - "integrity": "sha1-4N0hILSeG3JM6NcUxSCCKpQ4V20=", - "deprecated": "Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue", - "dependencies": { - "lru-cache": "2", - "sigmund": "~1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/glob": { - "version": "3.1.21", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "dependencies": { - "graceful-fs": "~1.2.0", - "inherits": "1", - "minimatch": "~0.2.11" - }, - "engines": { - "node": "*" - } - }, - "node_modules/glob/node_modules/inherits": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=" - }, - "node_modules/graceful-fs": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", - "deprecated": "please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/grunt": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/grunt/-/grunt-0.4.5.tgz", - "integrity": "sha1-VpN81RlDJK3/bSB2MYMqnWuk5/A=", - "dependencies": { - "async": "~0.1.22", - "coffee-script": "~1.3.3", - "colors": "~0.6.2", - "dateformat": "1.0.2-1.2.3", - "eventemitter2": "~0.4.13", - "exit": "~0.1.1", - "findup-sync": "~0.1.2", - "getobject": "~0.1.0", - "glob": "~3.1.21", - "grunt-legacy-log": "~0.1.0", - "grunt-legacy-util": "~0.2.0", - "hooker": "~0.2.3", - "iconv-lite": "~0.2.11", - "js-yaml": "~2.0.5", - "lodash": "~0.9.2", - "minimatch": "~0.2.12", - "nopt": "~1.0.10", - "rimraf": "~2.2.8", - "underscore.string": "~2.2.1", - "which": "~1.0.5" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/grunt-check-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/grunt-check-modules/-/grunt-check-modules-1.0.0.tgz", - "integrity": "sha1-Y/9erkYTF5tKifaozTcfekAfd4I=", - "engines": { - "node": ">=0.6.0" - }, - "peerDependencies": { - "grunt": "0.4.x" - } - }, - "node_modules/grunt-jquery-content": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/grunt-jquery-content/-/grunt-jquery-content-2.0.0.tgz", - "integrity": "sha1-jVFDOs0z/n7VL9956gAxwCRSwII=", - "dependencies": { - "async": "0.9.0", - "cheerio": "0.17.0", - "grunt-check-modules": "1.0.0", - "grunt-wordpress": "2.1.0", - "he": "0.5.0", - "highlight.js": "7.3.0", - "marked": "0.3.2", - "rimraf": "2.2.8", - "spawnback": "1.0.0", - "which": "1.0.5" - } - }, - "node_modules/grunt-jquery-content/node_modules/async": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", - "integrity": "sha1-rDYTsdqb7RtHUQu0ZRuJMeRxRsc=" - }, - "node_modules/grunt-jquery-content/node_modules/which": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/which/-/which-1.0.5.tgz", - "integrity": "sha1-VjDWgZ3aaS8UZEYueVbLQsCEJzk=", - "bin": { - "which": "bin/which" - }, - "engines": { - "node": "*" - } - }, - "node_modules/grunt-legacy-log": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-0.1.3.tgz", - "integrity": "sha1-7ClCboAwIa9ZAp+H0vnNczWgVTE=", - "dependencies": { - "colors": "~0.6.2", - "grunt-legacy-log-utils": "~0.1.1", - "hooker": "~0.2.3", - "lodash": "~2.4.1", - "underscore.string": "~2.3.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/grunt-legacy-log-utils": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-0.1.1.tgz", - "integrity": "sha1-wHBrndkGThFvNvI/5OawSGcsD34=", - "dependencies": { - "colors": "~0.6.2", - "lodash": "~2.4.1", - "underscore.string": "~2.3.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/grunt-legacy-log-utils/node_modules/lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "engines": [ - "node", - "rhino" - ] - }, - "node_modules/grunt-legacy-log-utils/node_modules/underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", - "engines": { - "node": "*" - } - }, - "node_modules/grunt-legacy-log/node_modules/lodash": { - "version": "2.4.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "engines": [ - "node", - "rhino" - ] - }, - "node_modules/grunt-legacy-log/node_modules/underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", - "engines": { - "node": "*" - } - }, - "node_modules/grunt-legacy-util": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-0.2.0.tgz", - "integrity": "sha1-kzJIhNv343qf98Am3/RR2UqeVUs=", - "dependencies": { - "async": "~0.1.22", - "exit": "~0.1.1", - "getobject": "~0.1.0", - "hooker": "~0.2.3", - "lodash": "~0.9.2", - "underscore.string": "~2.2.1", - "which": "~1.0.5" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/grunt-wordpress": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/grunt-wordpress/-/grunt-wordpress-2.1.0.tgz", - "integrity": "sha1-ty0EttVbQdFP/Yrq8W0ibFk9vl0=", - "dependencies": { - "gilded-wordpress": "1.0.0" - } - }, - "node_modules/he": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/he/-/he-0.5.0.tgz", - "integrity": "sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI=", - "bin": { - "he": "bin/he" - } - }, - "node_modules/highlight.js": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-7.3.0.tgz", - "integrity": "sha1-bF8PZOcHj2ZAK82/yJEQw/0bqZ8=", - "deprecated": "Version no longer supported. Upgrade to @latest", - "engines": { - "node": "*" - } - }, - "node_modules/hooker": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", - "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", - "engines": { - "node": "*" - } - }, - "node_modules/htmlparser2": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.7.3.tgz", - "integrity": "sha1-amTHdjfAjG8w7CqBV6UzM758sF4=", - "dependencies": { - "domelementtype": "1", - "domhandler": "2.2", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - } - }, - "node_modules/htmlparser2/node_modules/domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/htmlparser2/node_modules/entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=" - }, - "node_modules/iconv-lite": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz", - "integrity": "sha1-HOYKOleGSiktEyH/RgnKS7llrcg=", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "node_modules/js-yaml": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", - "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=", - "dependencies": { - "argparse": "~ 0.1.11", - "esprima": "~ 1.0.2" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - }, - "engines": { - "node": ">= 0.6.0" - } - }, - "node_modules/lodash": { - "version": "0.9.2", - "resolved": "http://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz", - "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=", - "engines": [ - "node", - "rhino" - ] - }, - "node_modules/lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" - }, - "node_modules/marked": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.2.tgz", - "integrity": "sha1-AV2xWIZEOPJKZL3WGgQotBhwbQk=", - "bin": { - "marked": "bin/marked" - } - }, - "node_modules/minimatch": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "deprecated": "Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue", - "dependencies": { - "lru-cache": "2", - "sigmund": "~1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/natives": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.4.tgz", - "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==", - "deprecated": "This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x." - }, - "node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/rimraf": { - "version": "2.2.8", - "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/sax": { - "version": "0.4.3", - "resolved": "http://registry.npmjs.org/sax/-/sax-0.4.3.tgz", - "integrity": "sha1-cA46NOsueSzjgHkccSgPNzGWXdw=" - }, - "node_modules/sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" - }, - "node_modules/spawnback": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/spawnback/-/spawnback-1.0.0.tgz", - "integrity": "sha1-9zZi9+VNlTZ+ynTWQmxnfdfqaG8=" - }, - "node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, - "node_modules/underscore": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", - "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" - }, - "node_modules/underscore.string": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", - "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", - "engines": { - "node": "*" - } - }, - "node_modules/which": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", - "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=", - "bin": { - "which": "bin/which" - } - }, - "node_modules/wordpress": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordpress/-/wordpress-1.0.0.tgz", - "integrity": "sha1-m+FQ5pObYUnVw0F017UIeOK7s88=", - "dependencies": { - "xmlrpc": "1.0.1" - }, - "engines": { - "node": "*" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "node_modules/xmlbuilder": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.3.1.tgz", - "integrity": "sha1-XtTCK0YiwkN/r4Pk8jbyPWu/JkE=", - "engines": { - "node": ">=0.2.0" - } - }, - "node_modules/xmlrpc": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/xmlrpc/-/xmlrpc-1.0.1.tgz", - "integrity": "sha1-QZcSWnn5mG1Ih2cVqC0Gj+8WiuM=", - "dependencies": { - "sax": "0.4.x", - "xmlbuilder": "0.3.1" - }, - "engines": { - "node": ">=0.4", - "npm": ">=1.0.0" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 77f8011..0000000 --- a/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "jqueryvalidation-content", - "title": "jQuery Validation Plugin site content", - "description": "Site content for the jQuery Validation Plugin", - "version": "1.0.0", - "homepage": "https://jqueryvalidation.org/", - "author": { - "name": "Jörn Zaefferer (http://bassistance.de/)" - }, - "repository": { - "type": "git", - "url": "git://github.com/jquery-validation/validation-content.git" - }, - "bugs": { - "url": "https://github.com/jquery-validation/validation-content/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://opensource.org/licenses/MIT" - } - ], - "dependencies": { - "grunt": "0.4.5", - "grunt-jquery-content": "2.0.0" - } -} diff --git a/pages/contribute.md b/pages/contribute.md deleted file mode 100644 index 6b403a0..0000000 --- a/pages/contribute.md +++ /dev/null @@ -1,11 +0,0 @@ - - -There are several ways for you to contribute to this plugin: - -* Help [with the code](https://github.com/jquery-validation/jquery-validation/). Fix bugs, propose features, translate messages and methods... -* Help [with the site content](https://github.com/jquery-validation/validation-content). Improve API documentation, examples, references... -* Help [with the site theme](https://github.com/jquery-validation/validation-theme). This is a WordPress theme that still needs a lot of improvements. - -The majority of contributions can be viewed under [jQuery's contribute site](https://contribute.jquery.org/) - the style guides et al apply to this project as well. diff --git a/pages/documentation.md b/pages/documentation.md deleted file mode 100644 index 97fa99f..0000000 --- a/pages/documentation.md +++ /dev/null @@ -1,212 +0,0 @@ - - -# Validate forms like you've never validated before! - -**"But doesn't jQuery make it easy to write your own validation plugin?"** -Sure, but there are still a lot of subtleties to take care of: You need a standard library of validation methods (such as emails, URLs, credit card numbers). You need to place error messages in the DOM and show and hide them when appropriate. You want to react to more than just a submit event, like keyup and blur. -You may need different ways to specify validation rules according to the server-side enviroment you are using on different projects. And after all, you don't want to reinvent the wheel, do you? - -**"But aren't there already a ton of validation plugins out there?"** -Right, there are a lot of non-jQuery-based solutions (which you'd avoid since you found jQuery) and some jQuery-based solutions. This particular one is one of the oldest jQuery plugins (started in July 2006) and has proved itself in projects all around the world. There is also an [article](http://bassistance.de/2007/07/04/about-client-side-form-validation-and-frameworks/) discussing how this plugin fits the bill of the should-be validation solution. - -Not convinced? [Have a look at this example](https://jqueryvalidation.org/files/demo/): - -

-
-
- Please provide your name, email address (won't be published) and a comment -

- - -

-

- - -

-

- - -

-

- - -

-

- -

-
-
- -
- -### Isn't that nice and easy? -A single line of jQuery to select the form and apply the validation plugin, plus a few annotations on each element to specify the validation rules. - -Of course that isn't the only way to specify rules. You also don't have to rely on those default messages, but they come in handy when starting to setup validation for a form. - -### A few things to look out for when playing around with the demo - -* After trying to submit an invalid form, the first invalid element is focused, allowing the user to correct the field. If another invalid field - that wasn't the first one - was focused before submit, that field is focused instead, allowing the user to start at the bottom if he or she prefers. -* Before a field is marked as invalid, the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages - they won't get bugged before having the chance to actually enter a correct value -* Once a field is marked invalid, it is eagerly validated: As soon as the user has entered the necessary value, the error message is removed -* If the user enters something in a non-marked field, and tabs/clicks away from it (blur the field), it is validated - obviously the user had the intention to enter something, but failed to enter the correct value - -That behaviour can be irritating when clicking through demos of the validation plugin - it is designed for an unobtrusive user experience, annoying the user as little as possible with unnecessary error messages. So when you try out other demos, try to react like one of your users would, and see if the behaviour is better then. If not, please let me know about any ideas you may have for improvements! - -# API Documentation - -You're probably looking for - -### [Options for the validate() method](/validate) - -If not, read on. - -Throughout the documentation, two terms are used very often, so it's important that you know their meaning in the context of the validation plugin: - -* **method**: A validation method implements the logic to validate an element, like an email method that checks for the right format of a text input's value. A set of standard methods is available, and it is easy to write your own. -* **rule**: A validation rule associates an element with a validation method, like "validate input with name "primary-mail" with methods "required" and "email". - -## Plugin methods - -This library adds three jQuery plugin methods, the main entry point being the `validate` method: - -* [`validate()` - Validates the selected form.](/validate) -* [`valid()` - Checks whether the selected form or selected elements are valid.](/valid) -* [`rules()` - Read, add and remove rules for an element.](/rules) - -## Custom selectors - -This library also extends jQuery with three custom selectors: - -* [`:blank` - Selects all elements with a blank value.](/blank-selector) -* [`:filled` - Selects all elements with a filled value.](/filled-selector) -* [`:unchecked` - Selects all elements that are unchecked.](/unchecked-selector) - -## Validator - -The validate method returns a Validator object that has a few public methods that you can use to trigger validation programmatically or change the contents of the form. The validator object has more methods, but only those documented here are intended for usage. - -* [`Validator.form()` - Validates the form.](/Validator.form) -* [`Validator.element()` - Validates a single element.](/Validator.element) -* [`Validator.resetForm()` - Resets the controlled form.](/Validator.resetForm) -* [`Validator.showErrors()` - Show the specified messages.](/Validator.showErrors) -* [`Validator.numberOfInvalids()` - Returns the number of invalid fields.](/Validator.numberOfInvalids) -* [`Validator.destroy()` - Destroys this instance of validator.](/Validator.destroy) - -There are a few static methods on the validator object: - -* [`jQuery.validator.addMethod()` - Add a custom validation method.](/jQuery.validator.addMethod) -* [`jQuery.validator.format()` - Replaces {n} placeholders with arguments.](/jQuery.validator.format) -* [`jQuery.validator.setDefaults()` - Modify default settings for validation.](/jQuery.validator.setDefaults) -* [`jQuery.validator.addClassRules()` - Add a compound class method.](/jQuery.validator.addClassRules) - -## List of built-in Validation methods - -A set of standard validation methods is provided: - -* [`required` - Makes the element required.](/required-method) -* [`remote` - Requests a resource to check the element for validity.](/remote-method) -* [`minlength` - Makes the element require a given minimum length.](/minlength-method) -* [`maxlength` - Makes the element require a given maximum length.](/maxlength-method) -* [`rangelength` - Makes the element require a given value range.](/rangelength-method) -* [`min` - Makes the element require a given minimum.](/min-method) -* [`max` - Makes the element require a given maximum.](/max-method) -* [`range` - Makes the element require a given value range.](/range-method) -* [`step` - Makes the element require a given step.](/step-method) -* [`email` - Makes the element require a valid email](/email-method) -* [`url` - Makes the element require a valid url](/url-method) -* [`date` - Makes the element require a date.](/date-method) -* [`dateISO` - Makes the element require an ISO date.](/dateISO-method) -* [`number` - Makes the element require a decimal number.](/number-method) -* [`digits` - Makes the element require digits only.](/digits-method) -* [`equalTo` - Requires the element to be the same as another one](/equalTo-method) - -Some more methods are provided as add-ons, and are currently included in additional-methods.js in the download package. Not all of them are documented here: - -* [`accept` - Makes a file upload accept only specified mime-types.](/accept-method) -* [`creditcard` - Makes the element require a credit card number.](/creditcard-method) -* [`extension` - Makes the element require a certain file extension.](/extension-method) -* [`phoneUS` - Validate for valid US phone number.](/phoneUS-method) -* [`require_from_group` - Ensures a given number of fields in a group are complete.](/require_from_group-method) - -You can find the [source code for all additional methods in the GitHub repository](https://github.com/jzaefferer/jquery-validation/tree/master/src/additional). - -It is possible to re-define the implementation of the built-in rules using the [`$.validator.methods` property](/jQuery.validator.methods/) - -# [General Guidelines](/reference) - -The General Guidelines section provides detailed discussion of the design and ideas behind the plugin, explaining why certain things are as they are. It covers the features in more detail than the API documentation, which just briefly explains the various methods and options available. - -If you've decided to use the validation plugin in your application and want to get to know it better, it is recommended that you read the guidelines. - -## Fields with complex names (brackets, dots) - -When you have a name attribute like user[name], make sure to put the name in quotes. More details in the [General Guidelines](/reference). - -## Too much recursion - -Another common problem occurs with this code: - -

- $("#myform").validate({
-  submitHandler: function(form) {
-    // some other code
-    // maybe disabling submit button
-    // then:
-    $(form).submit();
-  }
- });
-
- -This results in a too-much-recursion error: $(form).submit() triggers another round of validation, resulting in another call to submitHandler, and voila, recursion. Replace that with form.submit(), which triggers the native submit event instead and not the validation. - -So the correct code looks slightly different: - -

- $("#myform").validate({
-  submitHandler: function(form) {
-    form.submit();
-  }
- });
-
- -# Demos - -## [The Marketo sign-up form](https://jqueryvalidation.org/files/demo/marketo/) -### [The Marketo sign-up form, step 2](https://jqueryvalidation.org/files/demo/marketo/step2.htm) -Based on an old version of the marketo.com sign-up form. The custom validation was once replaced with this plugin. Thanks to Glen Lipka for contributing it! - -*Notable features of the demo:* - -* Customized message display: No messages displayed for the required method, only for typing-errors (like wrong email format); A summary is displayed at the top ("You missed 12 fields. They have been highlighted below.") -* Remote validation of email field. Try to enter eg. glen@marketo.com -* Integration with masked-input plugin, see Zip and Phone fields and Credit Card Number on step 2 -* A custom method for making the billing address on step 2 optional when "Same as Company Address" is checked -* A custom method for checking the password: Checks that the password contains at least one number and one character and that it is at least 6 characters long. If the user blurs the field with an invalid value, the input is emptied and gets focus again. - -## [The Remember The Milk sign-up form](https://jqueryvalidation.org/files/demo/milk/) -The sign-up form from rememberthemilk.com (based on an older version). The custom validation was replaced using this plugin. Thanks to RTM for contributing! - -*Notable features of the demo:* - -* Custom message display, based on the original table layout, using success option to display a checkmark for valid fields -* Remote validation of username, to check if it is already taken (try "Peter", "asdf" or "George") - -## [A multipart "buy&sell a house" form](https://jqueryvalidation.org/files/demo/multipart/) -Contributed by Michael Evangelista, showing a multipart form for buying and selling houses. - -*Notable features of the demo:* - -* Multipart, implemented using the jQuery UI accordion and a custom method to check if an element is on the current page when validated -* Integration with masked-input plugin, see Phone and Zip fields - -## [Using remote validation to help with captchas](https://jqueryvalidation.org/files/demo/captcha/) -Features remote validation for helping the user to fill out captchas. - -*Notable features of the demo:* - -* Remote validation to check if the user entered the correct captcha, without forcing him to submit the form first diff --git a/pages/index.html b/pages/index.html deleted file mode 100644 index d6df4f7..0000000 --- a/pages/index.html +++ /dev/null @@ -1,59 +0,0 @@ - - -

This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you’re building something new from scratch, but also when you’re trying to integrate something into an existing application with lots of existing markup. The plugin comes bundled with a useful set of validation methods, including URL and email validation, while providing an API to write your own methods. All bundled methods come with default error messages in english and translations into 37 other languages.

- -

For a quick overview of what this plugin provides, check out this Webucator video (they also provide jQuery trainings):

- - -

The plugin was initially written and maintained by Jörn Zaefferer, a member of the jQuery team, lead developer on the jQuery UI team and maintainer of QUnit. It was started back in the early days of jQuery in 2006, and updated and improved since then.

-

Starting with Version 1.15.0 Markus Staab took over the maintenance of the codebase in February 2016. Since July 2016 Brahim Arkni assisted Markus, and a few months later Brahim joined the jQuery Validation core team.

- -
Current version: 1.19.5
-
License: MIT
- -

Files:

-Download -Changelog -Demos -Documentation -GitHub Repository - -

Installation via Package Managers

- - -

-Latest files on jsDelivr CDN (hotlinking welcome):

- - -

-Latest files on cdnjs CDN (hotlinking welcome):

- - - -

Dependencies

-

Required

- - -

Support

- diff --git a/pages/reference.md b/pages/reference.md deleted file mode 100644 index 535c9b6..0000000 --- a/pages/reference.md +++ /dev/null @@ -1,129 +0,0 @@ - - -# Goals -The ultimate goal of this plugin is to make working with forms more fun for everyone. By improving the interaction, it is easier and less annoying for the user to fill out the form and submit it. - -To achieve this, it is important that the plugin is actually deployed on websites around the world, so a lot of focus is spent on making it easy for developers - that's you - to use the plugin. - -The plugin can never replace server-side validation and doesn't intend to do so. Having both in place gives you the necessary security for your application, as well as improved usability. - -# Markup recommendations -Mandated: A 'name' attribute is required for all input elements needing validation, and the plugin will not work without this. A 'name' attribute must also be unique to the form, as this is how the plugin keeps track of all input elements. However, each group of radio or checkbox elements will share the same 'name' since the value of this grouping represents a single piece of the form data. - -Optionally: Each input can have a label associated with it, where the 'for' attribute of the label refers to the 'id' attribute of the input. It's also a common practice to have 'id' and 'name' attributes with the same value, although keep in mind that since this plugin does not use the 'id' attribute, this is not mandatory. - -```html - - -``` - -# Methods -A validation method implements the logic to validate any element. Provided are a set of default validation methods, such as `required`. Apart from `required` itself and `equalTo`, all validation methods declare an element valid when it has no value at all. That way an email field is optional unless `required` is specified. You can specify an element input to contain a valid email address, or nothing at all. Use jQuery.validator.addMethod to implement custom methods. - -# Rules -A validation rule applies one or more validation methods to an input element. You can specify validation rules via metadata or via plugin settings (option `rules`). The decision is often influenced by serverside infrastructure. If a web framework is used, it is often easier to use metadata, which is also good for fast prototyping. Plugin settings produce cleaner markup, though valid markup results from both. - -## Fields with complex names (brackets, dots) -If your form consists of fields using names that aren't legal JavaScript identifiers, you have to quote those names when using the `rules` option: - -```js - $("#myform").validate({ - rules: { - // no quoting necessary - name: "required", - // quoting necessary! - "user[email]": "email", - // dots need quoting, too! - "user.address.street": "required" - } - }); -``` - -## Refactoring rules -Whenever you have multiple fields with the same rules and messages, refactoring those can reduce a lot of duplication. Using `addMethod()` and `addClassRules()` are most effective for that. - -Let's consider an example where you have ten customer fields, each required and with a minlength of 2. You need custom messages for both rules. To avoid having to specify those rules and messages again and again, we can alias existing methods with different messages and group them into a single class: - -```js - // alias required to cRequired with new message - $.validator.addMethod("cRequired", $.validator.methods.required, - "Customer name required"); - // alias minlength, too - $.validator.addMethod("cMinlength", $.validator.methods.minlength, - // leverage parameter replacement for minlength, {0} gets replaced with 2 - $.validator.format("Customer name must have at least {0} characters")); - // combine them both, including the parameter for minlength - $.validator.addClassRules("customer", { cRequired: true, cMinlength: 2 }); -``` - -With that in place, we can add a class customer to all customer fields and be done with it: - -```html - - - -``` - -You can also reuse existing methods inside other custom methods, to reuse certain implementations. For example, if you're writing a custom method for validating email addresses inside a single field, you could call the existing `email` method for each email: - -```js -jQuery.validator.methods.email.call(this, email, element) -``` - -# Error messages -An error message displays a hint for the user about invalid elements, and what is wrong. There are four ways to provide error messages. Via the title attribute of the input element to validate, via data attributes, via error labels and via plugin settings (option `messages`). - -All validation rules included here provide a default error message which you can use for prototyping, because it is used when no specific message is provided. - -The priorities are as follows: A custom message (passed by plugin options), the element's title, the default message. - -When using data attributes, you can set a generic message for all rules, or specific messages per rule: -```html - - -``` - -# Error message display -Error messages are handled via label elements with an additional class (option `errorClass`). The link between the message and the invalid element is provided via the labels for attribute. When provided in the markup, they are shown and hidden accordingly, and otherwise created on demand. By default, labels are created after the invalid element, this is also customizable (option `errorPlacement`). It is also possible to put them into an error container (option `errorLabelContainer`). To use a different element then a label, specify the `errorElement` option. - -# General messages -In addition to field-specific messages you can display a general "your form is invalid, please fix the highlighted fields!" message in a container anywhere on your page, eg. above the form (option `errorContainer`). The container is shown and hidden when errors occur and are fixed accordingly. The container for error labels (option `errorLabelContainer`) can also be nested inside the error container. - -# Focusing of invalid elements -By default, the first invalid element in a form is focused after submitting a form with invalid elements. To prevent confusion on the behalf of the user, the plugin remembers the element that had focus when the form was submitted, and refocuses that element. That way the user can try to fill out elements of the form at the end, without being forced to focus them again and again. This can be disabled (option `focusInvalid`). - -# Form submit -By default, the form submission is prevented when the form is invalid, and submitted as normal when it is valid. You can also handle the submission manually (option `submitHandler`). - -## Skipping validation on submit -To skip validation while still using a submit-button, add the attribute "formnovalidate" to that input: - -```html - - -``` - -This used to work by adding `class="cancel"` to the input, this is now deprecated. - -[Demo for the cancel button](https://jqueryvalidation.org/files/demo/errorcontainer-demo.html) - -# Validation event -By default, forms are validated on submit, triggered by the user clicking the submit button or pressing enter when a form input is focused (option `onsubmit`). In addition, once a field was highlighted as being invalid, it is validated whenever the user types something in the field (option `onkeyup`). When the user enters something invalid into a valid field, it is also validated when the field loses focus (option `onfocusout`). - -The goal of these interactions is to provide feedback as early as possible, whilst avoiding user annoyance. Displaying error messages before the user had the chance to even type something is not helpful. - -# Developing and debugging a form -While developing and debugging the form, you should set the `debug` option to true. That prevents form submission on both valid and invalid forms and outputs some helpful messages to window.console (available via Firebug or Firebug Lite) that help debugging. When you have everything set up and don't get any error messages displayed, check if your rules all accept empty elements as valid (like email or url methods). - -Some issues are caused by certain form element's names. A name you should avoid is "submit" (for submit buttons and anything else). Browsers expose form elements as properties of the form element, by their name, in this case hiding native methods like submit(). Just don't use name="submit" and you're good. - -# Validating multiple forms on one page -The plugin can handle only one form per call. In case you have multiple forms on a single page which you want to validate, you have to initialise them all individually: -```js -$( "form" ).each( function() { - $( this ).validate( options ); -} ); -``` -You can avoid having to duplicate the plugin settings by modifying the defaults, using jQuery.validator.setDefaults to override multiple settings at once. From fca72e853f594caf18a023b5fbcdddd79eefc059 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:28:37 +0000 Subject: [PATCH 09/22] Update conversion notes with cleanup details Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/5608e6dd-347c-4281-81b1-3c53a3aeeac1 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- CONVERSION_NOTES.md | 78 ++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/CONVERSION_NOTES.md b/CONVERSION_NOTES.md index b4202bd..3d85fd0 100644 --- a/CONVERSION_NOTES.md +++ b/CONVERSION_NOTES.md @@ -6,8 +6,8 @@ The `entries/` directory contained 39 XML files that defined the API documentati ## Conversion Process -1. **Script**: `convert_entries.py` - Python script that parses XML and generates Markdown -2. **Source**: `entries/*.xml` (39 files) +1. **Script**: `convert_entries.py` - Python script that parsed XML and generated Markdown +2. **Source**: `entries/*.xml` (39 files) - **[REMOVED]** 3. **Output**: `_entries/*.md` (39 files) ## Conversion Details @@ -36,7 +36,6 @@ The `_config.yml` has been configured to: - Define `entries` as a collection - Output entries with permalink pattern `/:name/` - Apply the default layout to all entries -- Exclude the old `entries/` directory and conversion script from builds ## URL Mapping @@ -48,30 +47,49 @@ With the permalink configuration, entries are accessible at: This matches the link structure already present in `documentation.md`. -## Original XML Files - -The original XML files in the `entries/` directory are: -- Excluded from Jekyll processing (in `_config.yml`) -- Kept for reference -- Can be removed once the conversion is verified in production - -## Testing - -To verify the conversion: -1. Check that all 39 entries are present in `_entries/` -2. Verify front matter is correct for each file -3. Ensure links in `documentation.md` resolve correctly -4. Test the GitHub Pages deployment - -## Files Created/Modified - -**Created:** -- `_entries/*.md` (39 files) -- `convert_entries.py` -- This file (`CONVERSION_NOTES.md`) - -**Modified:** -- `_config.yml` - Updated collections, permalink, and excludes - -**Preserved (for reference):** -- `entries/*.xml` (39 files) - Original XML sources +## Repository Cleanup (Completed) + +The following old files were removed as they are no longer needed: + +### Old Build System +- `Gruntfile.js` - Old Grunt build configuration +- `package.json` / `package-lock.json` - Old npm dependencies for Grunt +- `config-sample.json` - Sample config for old build system + +### Old XML Files and Tools +- `entries/*.xml` (39 files) - Original XML sources (converted to markdown) +- `entries2html.xsl` - XSL transformation for XML to HTML +- `notes.xsl` - Additional XSL transformation file +- `categories.xml` - XML categories definition + +### Old Content Format +- `pages/` directory - Contained old format files with custom JSON frontmatter + - `pages/index.html` + - `pages/contribute.md` + - `pages/documentation.md` + - `pages/reference.md` +- These were duplicates of root files which have proper Jekyll front matter + +### Temporary Conversion Tools +- `convert_entries.py` - One-time conversion script (no longer needed) + +## Current Repository Structure + +``` +validation-content/ +├── _config.yml # Jekyll configuration +├── _entries/ # API documentation (39 markdown files) +├── _layouts/ # Jekyll templates +├── .github/workflows/ # GitHub Actions for deployment +├── index.md # Home page +├── documentation.md # Documentation index +├── contribute.md # Contribution guide +├── reference.md # Reference documentation +├── README.md # Repository documentation +├── CONVERSION_NOTES.md # This file +├── GITHUB_PAGES_SETUP.md # Setup instructions +├── Gemfile # Ruby dependencies for Jekyll +└── LICENSE-MIT.txt # License file +``` + +All content is now in standard Jekyll/Markdown format, ready for GitHub Pages deployment. From 0d6d791ba0feac47192ab86353b1d8072bd67659 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:35:29 +0000 Subject: [PATCH 10/22] Update to Jekyll 4.x Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/b166165c-b300-451d-a303-726d7d88061c Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- GITHUB_PAGES_SETUP.md | 2 ++ Gemfile | 5 +++-- README.md | 6 ++++-- _config.yml | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/GITHUB_PAGES_SETUP.md b/GITHUB_PAGES_SETUP.md index 94dad0b..b8f3252 100644 --- a/GITHUB_PAGES_SETUP.md +++ b/GITHUB_PAGES_SETUP.md @@ -6,6 +6,8 @@ This document explains how to enable GitHub Pages for this repository. The repository is configured to automatically deploy to GitHub Pages using GitHub Actions. The workflow is defined in `.github/workflows/deploy-pages.yml`. +**Jekyll Version:** This site uses Jekyll 4.x, which is automatically handled by the GitHub Actions workflow. + ## Enabling GitHub Pages To enable GitHub Pages for this repository, a repository administrator needs to: diff --git a/Gemfile b/Gemfile index 1f885a2..6f5d4ad 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,8 @@ source "https://rubygems.org" -gem "jekyll", "~> 3.9" +gem "jekyll", "~> 4.3" +gem "webrick", "~> 1.8" # Required for Jekyll 4 on Ruby 3.0+ group :jekyll_plugins do - gem "jekyll-feed", "~> 0.12" + gem "jekyll-feed", "~> 0.17" end diff --git a/README.md b/README.md index 40d8bb7..0da33a8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This site is automatically deployed to GitHub Pages using Jekyll. To test the site locally: -1. Install Ruby and Bundler: +1. Install Ruby 2.7 or higher and Bundler: ```bash gem install bundler ``` @@ -32,7 +32,9 @@ To test the site locally: bundle exec jekyll serve ``` -4. Open your browser to `http://localhost:4000` +4. Open your browser to `http://localhost:4000/validation-content/` + +**Note:** This site uses Jekyll 4.x. If you encounter issues, ensure you have Ruby 2.7 or higher installed. ### Making Changes diff --git a/_config.yml b/_config.yml index f6ac7ba..4ffa553 100644 --- a/_config.yml +++ b/_config.yml @@ -5,6 +5,9 @@ baseurl: "/validation-content" # Build settings markdown: kramdown +kramdown: + input: GFM + syntax_highlighter: rouge # Exclude from processing exclude: From c368205253142ef54a9834c3c62f0f6020cf809b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:36:05 +0000 Subject: [PATCH 11/22] Add Jekyll 4 upgrade documentation Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/b166165c-b300-451d-a303-726d7d88061c Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- JEKYLL_4_UPGRADE.md | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 JEKYLL_4_UPGRADE.md diff --git a/JEKYLL_4_UPGRADE.md b/JEKYLL_4_UPGRADE.md new file mode 100644 index 0000000..6741667 --- /dev/null +++ b/JEKYLL_4_UPGRADE.md @@ -0,0 +1,65 @@ +# Jekyll 4 Upgrade Notes + +## Summary + +This repository has been updated from Jekyll 3.9 to Jekyll 4.3. + +## Changes Made + +### 1. Gemfile Updates +- **Jekyll**: Updated from `~> 3.9` to `~> 4.3` +- **webrick**: Added `~> 1.8` (required for Jekyll 4 on Ruby 3.0+) +- **jekyll-feed**: Updated from `~> 0.12` to `~> 0.17` + +### 2. Configuration Updates (_config.yml) +Added explicit kramdown configuration for Jekyll 4: +```yaml +kramdown: + input: GFM + syntax_highlighter: rouge +``` + +### 3. Documentation Updates +- Updated README.md to specify Ruby 2.7+ requirement +- Updated GITHUB_PAGES_SETUP.md to note Jekyll 4 usage + +## Key Differences in Jekyll 4 + +### Breaking Changes Addressed +1. **Kramdown Settings**: Jekyll 4 requires explicit configuration for kramdown input format and syntax highlighter +2. **Ruby Version**: Jekyll 4 requires Ruby 2.7.0 or higher +3. **Webrick**: No longer bundled with Ruby 3.0+, must be added as a dependency + +### Compatibility +- All existing content and layouts are compatible with Jekyll 4 +- GitHub Actions workflow (`actions/jekyll-build-pages@v1`) automatically uses the latest Jekyll version +- No changes needed to existing markdown files or layouts + +## Testing Locally + +To test the site with Jekyll 4: + +```bash +# Install dependencies +bundle install + +# Serve locally +bundle exec jekyll serve + +# Access at http://localhost:4000/validation-content/ +``` + +## Deployment + +The GitHub Actions workflow will automatically use Jekyll 4 when building and deploying the site. No changes to the workflow were necessary as it automatically detects the Jekyll version from the Gemfile. + +## Rollback (if needed) + +To rollback to Jekyll 3, simply revert the Gemfile to: +```ruby +gem "jekyll", "~> 3.9" +# Remove webrick line +gem "jekyll-feed", "~> 0.12" +``` + +And remove the kramdown configuration from _config.yml. From ef930ddbff1862695f57f615c5cede58f54288bf Mon Sep 17 00:00:00 2001 From: bytestream Date: Wed, 15 Apr 2026 14:45:53 +0100 Subject: [PATCH 12/22] fix yaml error --- _entries/date-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_entries/date-method.md b/_entries/date-method.md index 8b4a2b3..521da0c 100644 --- a/_entries/date-method.md +++ b/_entries/date-method.md @@ -1,5 +1,5 @@ --- -title: [DEPRECATED] date method +title: "[DEPRECATED] date method" entry_name: date entry_type: method return_type: Boolean From b6314142227c5956e54b6f9c47d75544729a44b5 Mon Sep 17 00:00:00 2001 From: bytestream Date: Wed, 15 Apr 2026 14:46:00 +0100 Subject: [PATCH 13/22] update .gitignore --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2c08b98..b844b14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -dist -node_modules -config.json +Gemfile.lock From 36ceeb4ba9a59748091958185c05fea65bdcb87b Mon Sep 17 00:00:00 2001 From: bytestream Date: Wed, 15 Apr 2026 14:48:42 +0100 Subject: [PATCH 14/22] update base url --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 4ffa553..f211c7f 100644 --- a/_config.yml +++ b/_config.yml @@ -1,7 +1,7 @@ title: jQuery Validation Plugin description: Site content for the jQuery Validation Plugin url: https://jquery-validation.github.io -baseurl: "/validation-content" +baseurl: "" # Build settings markdown: kramdown From 8cb9141ca25436548da5bc0372c37312466353a7 Mon Sep 17 00:00:00 2001 From: bytestream Date: Wed, 15 Apr 2026 14:50:22 +0100 Subject: [PATCH 15/22] update .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b844b14..9fd602a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -Gemfile.lock +/.jekyll-cache/ +/_site/ +/Gemfile.lock From 1def32575fdda92b9dcbc713a8e09e504e8fe7e2 Mon Sep 17 00:00:00 2001 From: bytestream Date: Wed, 15 Apr 2026 14:50:31 +0100 Subject: [PATCH 16/22] remove copilot generated pages --- CONVERSION_NOTES.md | 95 ------------------------------------------- GITHUB_PAGES_SETUP.md | 56 ------------------------- JEKYLL_4_UPGRADE.md | 65 ----------------------------- 3 files changed, 216 deletions(-) delete mode 100644 CONVERSION_NOTES.md delete mode 100644 GITHUB_PAGES_SETUP.md delete mode 100644 JEKYLL_4_UPGRADE.md diff --git a/CONVERSION_NOTES.md b/CONVERSION_NOTES.md deleted file mode 100644 index 3d85fd0..0000000 --- a/CONVERSION_NOTES.md +++ /dev/null @@ -1,95 +0,0 @@ -# XML to Markdown Conversion Notes - -## Overview - -The `entries/` directory contained 39 XML files that defined the API documentation for individual validation methods, selectors, and validator functions. These have been converted to Markdown format and moved to the `_entries/` directory for use with Jekyll. - -## Conversion Process - -1. **Script**: `convert_entries.py` - Python script that parsed XML and generated Markdown -2. **Source**: `entries/*.xml` (39 files) - **[REMOVED]** -3. **Output**: `_entries/*.md` (39 files) - -## Conversion Details - -Each XML file was transformed as follows: - -### Front Matter -- `title`: From `` element -- `entry_name`: From `name` attribute of root `<entry>` -- `entry_type`: From `type` attribute (method, selector, validator) -- `return_type`: From `return` attribute (if present) -- `category`: From `<category slug="">` element -- `layout`: Set to "default" - -### Content Structure -- **Title**: H1 heading from `<title>` -- **Sample**: For selectors, the selector syntax from `<sample>` -- **Description**: From `<desc>` element -- **Long Description**: From `<longdesc>` element (with HTML preserved as markdown) -- **Usage/Signatures**: From `<signature>` elements with nested arguments and properties -- **Examples**: From `<example>` elements with JavaScript and HTML code blocks - -## Jekyll Configuration - -The `_config.yml` has been configured to: -- Define `entries` as a collection -- Output entries with permalink pattern `/:name/` -- Apply the default layout to all entries - -## URL Mapping - -With the permalink configuration, entries are accessible at: -- `/validate/` → `_entries/validate.md` -- `/required-method/` → `_entries/required-method.md` -- `/blank-selector/` → `_entries/blank-selector.md` -- etc. - -This matches the link structure already present in `documentation.md`. - -## Repository Cleanup (Completed) - -The following old files were removed as they are no longer needed: - -### Old Build System -- `Gruntfile.js` - Old Grunt build configuration -- `package.json` / `package-lock.json` - Old npm dependencies for Grunt -- `config-sample.json` - Sample config for old build system - -### Old XML Files and Tools -- `entries/*.xml` (39 files) - Original XML sources (converted to markdown) -- `entries2html.xsl` - XSL transformation for XML to HTML -- `notes.xsl` - Additional XSL transformation file -- `categories.xml` - XML categories definition - -### Old Content Format -- `pages/` directory - Contained old format files with custom JSON frontmatter - - `pages/index.html` - - `pages/contribute.md` - - `pages/documentation.md` - - `pages/reference.md` -- These were duplicates of root files which have proper Jekyll front matter - -### Temporary Conversion Tools -- `convert_entries.py` - One-time conversion script (no longer needed) - -## Current Repository Structure - -``` -validation-content/ -├── _config.yml # Jekyll configuration -├── _entries/ # API documentation (39 markdown files) -├── _layouts/ # Jekyll templates -├── .github/workflows/ # GitHub Actions for deployment -├── index.md # Home page -├── documentation.md # Documentation index -├── contribute.md # Contribution guide -├── reference.md # Reference documentation -├── README.md # Repository documentation -├── CONVERSION_NOTES.md # This file -├── GITHUB_PAGES_SETUP.md # Setup instructions -├── Gemfile # Ruby dependencies for Jekyll -└── LICENSE-MIT.txt # License file -``` - -All content is now in standard Jekyll/Markdown format, ready for GitHub Pages deployment. diff --git a/GITHUB_PAGES_SETUP.md b/GITHUB_PAGES_SETUP.md deleted file mode 100644 index b8f3252..0000000 --- a/GITHUB_PAGES_SETUP.md +++ /dev/null @@ -1,56 +0,0 @@ -# GitHub Pages Setup Instructions - -This document explains how to enable GitHub Pages for this repository. - -## Automatic Deployment - -The repository is configured to automatically deploy to GitHub Pages using GitHub Actions. The workflow is defined in `.github/workflows/deploy-pages.yml`. - -**Jekyll Version:** This site uses Jekyll 4.x, which is automatically handled by the GitHub Actions workflow. - -## Enabling GitHub Pages - -To enable GitHub Pages for this repository, a repository administrator needs to: - -1. Go to the repository **Settings** page -2. Navigate to **Pages** in the left sidebar -3. Under **Build and deployment**: - - **Source**: Select "GitHub Actions" -4. Save the changes - -## After Enabling - -Once GitHub Pages is enabled: - -1. The workflow will automatically run when changes are pushed to `main` or `master` branch -2. You can also manually trigger the workflow from the **Actions** tab -3. The site will be available at: `https://jquery-validation.github.io/validation-content/` - - Or at your custom domain if configured - -## Testing the Deployment - -After enabling GitHub Pages and pushing changes: - -1. Go to the **Actions** tab in the repository -2. You should see the "Deploy to GitHub Pages" workflow running -3. Once complete, visit the deployed site URL -4. Verify that the content displays correctly - -## Troubleshooting - -If the deployment fails: - -1. Check the workflow logs in the **Actions** tab -2. Verify that GitHub Pages is enabled with "GitHub Actions" as the source -3. Ensure the branch being deployed (main or master) exists and has the latest changes -4. Check that all required files are present: `_config.yml`, `_layouts/default.html`, and content files - -## Custom Domain (Optional) - -To use a custom domain: - -1. Add a `CNAME` file to the repository root with your domain name -2. Configure your DNS settings to point to GitHub Pages -3. Enable HTTPS in the Pages settings (recommended) - -For more information, see: https://docs.github.com/en/pages diff --git a/JEKYLL_4_UPGRADE.md b/JEKYLL_4_UPGRADE.md deleted file mode 100644 index 6741667..0000000 --- a/JEKYLL_4_UPGRADE.md +++ /dev/null @@ -1,65 +0,0 @@ -# Jekyll 4 Upgrade Notes - -## Summary - -This repository has been updated from Jekyll 3.9 to Jekyll 4.3. - -## Changes Made - -### 1. Gemfile Updates -- **Jekyll**: Updated from `~> 3.9` to `~> 4.3` -- **webrick**: Added `~> 1.8` (required for Jekyll 4 on Ruby 3.0+) -- **jekyll-feed**: Updated from `~> 0.12` to `~> 0.17` - -### 2. Configuration Updates (_config.yml) -Added explicit kramdown configuration for Jekyll 4: -```yaml -kramdown: - input: GFM - syntax_highlighter: rouge -``` - -### 3. Documentation Updates -- Updated README.md to specify Ruby 2.7+ requirement -- Updated GITHUB_PAGES_SETUP.md to note Jekyll 4 usage - -## Key Differences in Jekyll 4 - -### Breaking Changes Addressed -1. **Kramdown Settings**: Jekyll 4 requires explicit configuration for kramdown input format and syntax highlighter -2. **Ruby Version**: Jekyll 4 requires Ruby 2.7.0 or higher -3. **Webrick**: No longer bundled with Ruby 3.0+, must be added as a dependency - -### Compatibility -- All existing content and layouts are compatible with Jekyll 4 -- GitHub Actions workflow (`actions/jekyll-build-pages@v1`) automatically uses the latest Jekyll version -- No changes needed to existing markdown files or layouts - -## Testing Locally - -To test the site with Jekyll 4: - -```bash -# Install dependencies -bundle install - -# Serve locally -bundle exec jekyll serve - -# Access at http://localhost:4000/validation-content/ -``` - -## Deployment - -The GitHub Actions workflow will automatically use Jekyll 4 when building and deploying the site. No changes to the workflow were necessary as it automatically detects the Jekyll version from the Gemfile. - -## Rollback (if needed) - -To rollback to Jekyll 3, simply revert the Gemfile to: -```ruby -gem "jekyll", "~> 3.9" -# Remove webrick line -gem "jekyll-feed", "~> 0.12" -``` - -And remove the kramdown configuration from _config.yml. From c9d479f450c7489aae2d5066bcf988adfd6fb157 Mon Sep 17 00:00:00 2001 From: bytestream <kieran@supportpal.com> Date: Wed, 15 Apr 2026 14:51:31 +0100 Subject: [PATCH 17/22] update exclude list --- _config.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/_config.yml b/_config.yml index f211c7f..f412d00 100644 --- a/_config.yml +++ b/_config.yml @@ -11,17 +11,12 @@ kramdown: # Exclude from processing exclude: - - node_modules - - config.json - README.md - LICENSE-MIT.txt - .gitignore - .gitattributes - - dist - Gemfile - Gemfile.lock - - GITHUB_PAGES_SETUP.md - - CONVERSION_NOTES.md # Collections collections: From 76ffa0f2d63130d2175590d0c6eb02b16d3058e5 Mon Sep 17 00:00:00 2001 From: bytestream <kieran@supportpal.com> Date: Wed, 15 Apr 2026 15:15:07 +0100 Subject: [PATCH 18/22] add logo and update colour scheme --- _layouts/default.html | 21 +++++++++++++++------ assets/jquery-validation-logo.webp | Bin 0 -> 9330 bytes 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 assets/jquery-validation-logo.webp diff --git a/_layouts/default.html b/_layouts/default.html index 46f2ccc..91407f5 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -15,27 +15,32 @@ color: #333; } header { - border-bottom: 2px solid #0066cc; + border-bottom: 2px solid #BF0130; padding-bottom: 20px; margin-bottom: 30px; } header h1 { margin: 0; - color: #0066cc; + color: #BF0130; + } + .site-logo { + display: block; + max-width: 100%; + height: 130px; } nav { margin-top: 15px; } nav a { margin-right: 20px; - color: #0066cc; + color: #cc005f; text-decoration: none; } nav a:hover { text-decoration: underline; } h1, h2, h3, h4, h5, h6 { - color: #0066cc; + color: #BF0130; margin-top: 1.5em; } code { @@ -55,7 +60,7 @@ padding: 0; } a { - color: #0066cc; + color: #BF0130; } footer { margin-top: 50px; @@ -71,7 +76,11 @@ </head> <body> <header> - <h1><a href="{{ site.baseurl }}/" style="color: #0066cc; text-decoration: none;">{{ site.title }}</a></h1> + <h1> + <a href="{{ site.baseurl }}/" aria-label="{{ site.title }}"> + <img class="site-logo" src="{{ site.baseurl }}/assets/jquery-validation-logo.webp" alt="jQuery Validation Plugin"> + </a> + </h1> <nav> <a href="{{ site.baseurl }}/">Home</a> <a href="{{ site.baseurl }}/documentation/">Documentation</a> diff --git a/assets/jquery-validation-logo.webp b/assets/jquery-validation-logo.webp new file mode 100644 index 0000000000000000000000000000000000000000..29ed1afb04db5595c0fdc4e9451039cb8e76cb32 GIT binary patch literal 9330 zcma)iWl$Wz((U5z4#8c5ySr-$?(XjH!GpWI26rd81qf~-xclPE?#p-Y_v-z9UDb0= zo$5OCXJ)FVy1yvM%G%Qa06H>~>e}l3y2t<k0P$baKm*nQfPV@_95n!toCzp^Vxom! z2Z(y{W+~8=mQqr;5w9ns$67e=dEDOW7lb!MYD20XpdNB2gDEVF4y!nS;#{xYhj{Mt z^s|L{J;HrxK#V@B8WD0_Hpn*{eaXj60!-F}w+6(;vO_E$8y<at7$1eey^od`C-4Y( z_i1ah2m)^2O@mZ|<$RexX5I&{o}W#qAj}^D_q%I0yxt`smy5L{vHsvAusJ9R!ZmD? z;vWtc0nLE2jye$z58uMyhaX)YO?E+gVp~A2i?!Fmt0DmTBBTK_bYF8D1l%=cI~MyR zX5Aku_6X5Cr3Z!pi$IWd5K@Q$cnjjP#<vc+A!xO^uHmx?`n4v|nZNbR>4f(o&u^~p z_>YIn|Cg{C$W3o&AZ9xo=EVT#jtAV~f;0}2ii|h~^aQe=6ptgSe!bKaNPM7E@E;rR zrEcCoz_mh6eaa&xd&faow+#7`fKU)KwBrUKYpEq>9sG@k5>nb?trLtW{$$ZGyi|Vy z!j4(+(j~^-mj5hACWA)4>8d`*&lrm%F;<U_YtmbJNgOf>?l*))B(jdFNHR*zIEMAX z;MKf}UbFIv>lEgfIl1MPP|~;rr}Af*0`h*RYSZCW3A=y^_zNTi6$18~Aw<uYpyIfU zD*9(D<Eg4$CBM+;z8Ej?FPC^xk1N{-kKU#H{W5qYo9{_st4RnA=k9<(ht*yGJSwr) z>{my6Uv$pMSkl9xJAF3U)7r1@Ag|kK=Lso_Mm{g|ZXcZ=mqwNQor6?+`%JZh2$(nw zHf`|+Ob?R|L_LlK2N`Tu(G*ZlNT}mBaPe+f`98X%;xlr`jpQ(d$G63}?Z^%*4Ym>S z+|5F;rrzPZ6?J-#aWwRFt_nsd@<s~JrG24khR4e?04Z>VL<Z@}T?~M!PSxNq!DCT@ zWO22(Z)nMd{d*Q{b>s!l>)h+3e@a2yq>zhxw0jP@fmRPiJL6E{VHx5XlqZI$KQX4* z6?dPApe*DEB<7E}G;ZTqMxt_BnOuGP#A0S)H_%j;7ImQ1Kt6KpuB;q?o3+M{NsT*o z-ddwsw#UAJQp3L0BP2Th+Piyho$_ju;)y<%w^O0|;%jCCk`kCg_UU3s)x@yy@ux3H zy0&XR7!WpQ>_gTDa6EZp{K@S&6%f^;V&KF40sQJ)CRd_)xV3j(z)Zh|0p{DbA_rc4 zu&iJHT4}7u4^8o**sCkj#_PDtKPk3f!2E6cr{fWZ*>kEgEu{F1qlUqkNN36%Ix1gV zHy5N+wL#TPjVYda^?ez4VOgjT&N8uHpf?**6-PyvCDX-hO9d4$yfXj2{7S5(D#8f1 zu#GMLL8oHs=A5w{muTeV!|3aJORg_T3<=wKcRC{8J>05I$lx)LT1ZtvgNF-mOM`b2 zHXPK(i9dC!l!m?JNrYc$;btqp@!_CZ5_kIvEy<ktf&XlRL?#6<Jy#1Cwf(-8l(l94 zfXrakCH6OxG&5XInZMQYt|tx!HmK)wA&34pI<5@#_sW@Q9{(SA(FXtkLozA;J!$_9 zbOQHx<|7-pP$z?>9hZ+iBPyV<rzd`Wz$l{k?w?nJ@hJR<6^vhkGWJW(iT%2$x?dTp zRX{LB+2xGyT4)c<gVJ`q2o3U*>v}35d7>C+Up89!qMoZ?Y-M$95loBCxevG$qLVMz z%`oiYHoXh~Xe2QU%3m+r9nl!Ih1(oznx$S9upm7yA~IM+y3K28dQdN^T(h!7`9l9C zkS_EjA<Mhfb7*>`*OnBS2SR=A`@!3lK37Og{DGQfnsoVTEAU>DB;1oAJzI!LxaLo6 z7%>NpH8c|2Wpnru{^<{k--N%t*bj{hB8}#pt!{@bYu24OH~QE#(Svk5m7U{RLgG=t z837oDtlBb0^xkyrD-I>(D=Kr7S@7jc$6f)xc%`H6aeaHFnpducCW#)9ey0#%A@=l3 z)7ZCH)t*sfPb6D~!qUsQ?+g1Z8p<fIFpoW&4+GPPcH%N2YS!28>O<n6=$k!B{j%33 zcG6_@33A}v44PdRdNSUsxs^~k^-DrSi>7%)u9r=)F0Kk@_Tc~8;8dV@R5Oy?f@+m? z`gI3#Bn`3Q_XS^gCTRQxGG}D$V5M{w%_mS=(+CK6FhPLKDT}oQ_xlE)Fhput&Bm^5 z_@2;5m$hXRaU3;|*MMA0DU5g9r1vog$`L!IMT3#!gza0F;(-So&uqBfUSwy=x8GP# z^I+Z#-J~x}FJboT`II$h0ld)&&fQLK(z4D7<=kBwO*eh>B3=e}PfR=}WcQv|CeK;> z2Y)0Z&i)Fl&(@NbsA*W?On!Z%iuE}Sm{81XT%7N03eEc*_Ep9cem=ZhVDtEbJ8z|N z;0(LHw=$VB)10>k@r#ShRIjiZW%w7IlVJYEx8_bnWD?1&=w#i&DI6FOk7Gd9(??$a zTbw%On(-~=`EE3Gb5E#2M-84!q<09bam<CAJ;ei$k}r&p=UPZp`Dr-@XA*F5*m~5X z&q#{IqT@Dm=O8q8<cp^Y^l0mY{-PuSA9L5^f+n#8x;b>(Y0duO#No0^$Kl$~l5Ors zy6<)NPj-gwFj>3FF!fD(ElBB1zUE~P{oi4Bvs;D{ntlZ{{lN<GSp0j4s}r}#C!Wba zdu7v;hFQuZ!CK>c6<Mo@>sw`&CaR{?54-2BBkLMGu^+qhK24aP<4J}+^{m1qVNc3x z`wF+NB9$`UD!%BGVZf=|Io{>+8%+jxFn?Lx{4-A^l)Mu$hQkv-NV}pGxX?k2T;=(U zis?l%F{VE;uU6HyR%wjrmUqi1kJ@eM#Yt<E)Tb|io1<zCsr$mWvh9-)k1(-Dvaj!? zbJ>@%6%dByTElz$hNfwgzo-q}BSRF$qd7l9ngUx~$j5@NRq@v12}3Lc&s<jh!$C&J z#yFUWCgAxbU?L1B<>x;CEah2C6cY#dZV>zg=&t~kK2kAnBlxJgm=2aGF5?_y=lZ3Z zESrT2j{54WioW;0TlnbWbtZ^hv!<xp>K*5TGur}&ehd1=d-mKYRa1bB{WOYSf|js) z*>OVxUM~s>WVgFsNOH5G4ZS1TUN#a%MF)oZJ8lPH2u88`A_S})*5tPSLjP$tSF$X5 zW{KoWvTbBcFVhRjsFNw!Xg{AI*m+yXOoC-Rz8Q)fEBIT^@v2ng@V2|PbV;V{FbLYl zMc+wkG^NUpa<`Uw>RvAz>vUJOa^Af#ReOT5S*cdE2)zf^&g5Eir(Uc%B&YhFs3%HB zb(T$38rs=f!pfaKX~FdD^m==yJae=;c9fr5E@*nP;qn2+?>dWZi;A(clG9eUys`rV zzA#pkK7w(?emIg`o5Ymdkk{AatrtlS8Co?5E4Z~%8|bL$bR*Oop6c(=VLVBo<h6tw zGLLd$vh~x*yO1PixoG#h7PHLLOhWQ=ZFpDBXy81`tK>y__$nOnNzuX+Z*in9Q47Bf z2Hpwfl2Fyt0NdsfF)T#zKQ9{F(JFB;Briq!f}+FbpEtW^%d3gzWg$uUV*8zn6<-Mf z1u+bM`UfYZ177;pT3=B!3&xcjBuwYk6p<1mcTUeA9AC32<SVxe(@hDaDrSk8bJag5 za(+**vBOtZL>oY?yX4j+c$5|iIOo(>6wM_K#6qi*(w>)1OGIx~yn>E5`JtS2ALOZx zHI{a7uey&agty`JsV=zn2utkf6l9g0lkZT-VSKVuOtVfeN|zYF4a%?BcsqSWX-eNl z`pk4D|Dh`Q=0D#>T`Z#Ff*TpOf1T~x;9FRI9$Ys18tc2x95<06{&Bi;y@XQo)uqT5 z;fEokbJC0!)AnsMJnu%Dqu_wIEML38%yoonF0!4=a`>os@L9oe^w{SyyWaW%NcCiO zTd_jE={XfUXILvAw*U6s#yLqLp@zvbwAB$drZ@MQj%BVc!;fJ@O17r2iE^41=Zps` zU4<+@faDkT)alut8o^fC6eL8c`>>&HPMf!cajd#rs2>AN(-*&6-%lol@}vY?*XZyS z$RAK|XThjCR{LZ?k}hj?L!(U6J6pEW@dIs+Q@b$$y+vSI3d|KG@ELN%xmjh&9NI`4 z<o}GVLdM-2KZ40bzUnX5RXk@fZ&q(m|I%tGpYcvRw%I61d5QBKZNQV3OnR6SpD&k6 z|0KBxSjq-2Je!wc#Wl_UDF+Y|O|O?VplB#wh;PV#zZzF+vTqYIr1k%}b>+(WP}=(< zYWBQE3Wl@$uHMR{a-4h&(^e<kPzX{)H|*-8QVRmnp1K{)j1SH=#k2pNRZ@^hbQvCl z?$?VnP+3as8t?na!`7~k;}!aZd8NvMUnk5k(SK6^QP~+{T2$O@0`J0u(7ETL@JIC> z#rGSF#^TtuL9}xG(M5KrKC64Y=l%&Y7YV9ofloIl4Uu$;{c<Jj4T4s5aXc+uP9?lM z6o9DI)^MaAO~C<PGY^u_<2Cw8EvpkUmbT+6XS97trkkFSh?x<J9wknVF<r5f*?$fj zdE-b}F`vQDN-MnCYoXw3Z?o|hs>3hZiaMI_6l}@1(D?zINinS7C~+LiU_AIUckzJ& z=jRm}M!*`@c)>Aa2(D3daG>Kk*8mfj$M?fI=o)2$R?O1rx0t~FO6KR4uEQn<p?6X& zpV$h(sId}S$_ub3=9)J}ZJ7;B^SZu#u1b5;-~Y|H6w^&eP?G|h?6nyGK;+$RWEQ_F z7E0LD#$*_%BC#IR6bQkWlpbbX3@T{V+4a(ig|~I6=R*J;aYuPwfwEM9f*Yh5m{%j^ z9z?jh&f}IMU@b4O{oab}1ahppp$WMV?<CN)r?{v8-fd|>6gzjiLsj+PX_)R&lIywa zLI}@%X4$7a)W-JOnweMP^D}&<J&(tUg@>9U<wm}PHtTu2BzyCAS{a^Dh)Ul?gw=T# z8hOS(^$t0j`2L3d;}`Z^!#R-uq60hg=()Y)-S+9G&H-R3$_bu9%fMQ}#&@h?A?HU3 z2kROg2@FFs&tG&R?VC&-L58H%Tso0A{keZxS@zH>bBH>y8jL7LP_jB$mka%(I#5FL zPXiObwjf?{%?3Z@Aa}O#o<J*NO+@>Z_#KG)cV)!K8_ra}bhNR&bpsk+ZNx7zLq~NK zG3H9!gO{>@c#G*oQ`@Kda7L5tU>K<1OAvi($d_}1ndt1QpecRNUE6NoF(eHfX#0{8 zzDUoYIqUG#lH$G#M&T-w7gu%gX@^iF7Bx-B%jxf4@`4WM3_^8e9&?}j)Q#uoQq!i* zI#(MYZC{<ExX7mZD`>$ZLI0@3KON%|yRb||s^e;J!3cJDfA#r(l?K`Vy$OYA(DjW< z!#$7?=^}j-c?++lKuIFX2;!_cQrbB3Nc0te9ygF+-J2(QMym^50OcTwgLc$C@pwz{ zI=BGhKJ4=0muJO)tZgNQGbYkk6?RxY<Zd>GI+@!q`XL&d*CI^Jqp@0c&9PAjYz=8l z1v^R7SQ<6L;fdKCB}p4|mLWqfv;6P+?7WZ|_n%TwUy9*Sa#+m4-x{TSHqFIYNKPNu zo7}W@r&x91&A#j4GY$`~RrYftPKM+1u^l*(2F6}?9Q^&9w;Ihikf;Vt*UA$u+YNv! zm=FarucufL?2#sN8e<vgkkM_^WH<0qTyC-A;%)FpC~6R{Nh!okj%Jr|!kKz?D7WuT zKLir?-?Lk)8kkFv=Jg~mqHBE9Rf@IG&;-viKSVOjVz?tcAdv1;2e%lnv^h5az@B>G zWngc|>oU{xz`WD0DGAHeLq`dN=|`PmICVa%XNMb)|Ab9dFWR#ARz-OJ@ALSAOOIKc zQ*_FVXDR(ak-jvbgj*{(cVLCwo9!0#v}Vpuw}&aW)Bq)YMP;Ng_$jTc4={@~n3Ie- z;I6eBEbRp3p}mdvjCT_X{z!AQ*qRNWG-zR)!?F(UcL;m$+u$>|19E@jlqHCQok8l~ z0C@?qB5S$6<R86hW)VTKf^d`EjwPxte$Nq`5c^#BP%9i(owPJOnI}om4eKsbR4;T< zZko8Itgb(ab70T-NjVS~rL?N)YIfP{#+O$EZQc>4h@p2NOA+ArLwnW{3>xH@ZG9BJ ztCD0fY^KlGOmwme@>c>bRU7?mDkzokZZIW5yydH;pQ)cKd*KFs9V~VTy6^I6XsO$L zO?|Bcm#6TAu008(WIS#@)HLDKo7$!or@^z(n;~<Q#-G|8rLxK2Bk-wgCF**L9BH|+ z8c>qmBp!&S4)wwERzA^)Mw6zA8whnV34cFuIOE-t`_hv*C$zsr{&~$oA;CDhc=m3@ z7uQsTD1q^`8K*?vdO~2j+aBe@5VdZ7u$vGtdRKzm(qsD6&PkR!r3K9I5Ll>%@|f-V ztwoBSr_L{wVa;A~XTJj2_AsXU_v4*uJ{UuX>IMelYQIej^NJG75lWf6sof-~rAZoV z1{+-_=QEqO`Q9wAPMx-*NnfqDvcl<Q3T1U28ACfXojN4T32?Y2C_-&DUywWGQG`lG zc|-=xK;pR`iuRe?!?M~Mu_QN3jl-E+=F*viM<evy4KV8%B?LZ_eal?j)*-)$igTDl z@fsHx<TVOuqAm$i<3y#iBWs==2;vC#m^7uQetRM{Gn3UzQQL5wCc7DbXGFY`B{6!X zu07FOpvKA_f*CGm_c}aMZb1oJ9yesqH=twFzS(HUYt296#79~3SE{jth*(y_yX0lo z(ZnJj0I{+3HvM&41FKn5CAbS8(sryE)na4|Lb}z9&au*82sX|S*={MtCayyG=59bf zc818Fu}jD7!E76j)};OkBf@y!pQwd5ak9W0Xfun$#8&JarNHLtF7R7@mprMpx=ZD+ z5)6enxAa70oQctvOKuF@LTCOY2+1iU`C{V*7TVA^wB+CvSj&=GG0hU7723<1Q0vk= zbU6o?><Quffec~x&wTOUL>qW-qabcH^~>yhP_Uu(P-yoG+V2;{gjbEqiK_x=!F~Xv z!WOl0#!xcLk;pV|nV9~mCiN<DnkAVIV||ys3eDD`U&!Emd72yGwdAkB7rK|CpB;CX zNwk%sHX9u0DQC5phc)`K04*VeNq={}Z)Q(CW(vQ3ZzOgK09S9BKT&#pHV#(O;%v6f zN&HA$zJt+^9pQlLnRK;(=H5P1YkVUTc?BlByy0T_>~IcYFBf^Jq|KwzCfY6$d~8X} z0uvI9ff-nUVA->8REFBT7kq|}-rA(-3`Flv!Zm@2T}599qRWs+0RX74`_AN62ta+~ zFY>oqB*@O%Ye7;xxZ=)Z9=FaIL@)~gV)`S+{AxSfq;fR7ZYktK5r<?qJVe)u@U@s# zq2?W>QFUIA-!)hZ&;%b^PP433Z!#V<aGY3^vq+aMA@<!=CA<z29m0mNThg2hEmKL8 z;0!(jM>?elx}}M;ADx3I)@(&j_MvSlZs+92zpuxYU!y_Dnrm*v7f&TzCVJfTJf0sN zAF&$kfdz&tO3LQ!EpwNjG$}{;HlWGbkIXU92zNR)kGVUa{MmslCqX+j(t^J{t|&w8 ze;)XT6%8O8Ihla`s6Kt^*nd~n=N?@(7XQ+RqX&V+Xe$2bT`CeCYKnfCV?}fLdlSJ- zC))qqyGq>*`|@iG9$d&=pV7c^;9{qaa7g<$;P&*+gVq#|pEzd8yuer0u7>{13wmY{ zgc=%1>THn^=8{RCrYk6#TF@FE<DeJHz7DRA)Zv7=2(9^9UWJFr%3D4I^w!cl!@<%o zS_?kxj`+dN)*-*wnujM)%PR1LB#Q17!I>FjsAQcQBG`!J#G)BxLKugZ(Z>XHluG3_ z&c<^dUjx^uJRvAb^s_o%QuFWffV=)&e=P||9f3%mj8eA0fP-6~=v)aqz@zx2I2PCb zA{9+ho^|}???r#LYvmSYbH)Pc)Y&sLr=s%JFI4dT>aU>BQ`k)tgF3=2<uIWxpO1PS z#KgB5x_fhDP>)&U51YsBIvuxdGk)}V-nD&Hd@G*P4y=9mP#?CbU$h+=++$?S{3}I( zNOefVbzltZI`9hiR}KjtJW;%b;H>W=D-NTROvh~NeJY+LWQ8t?W{nr1>99pv`Lh*5 zkN0!~z;CpH-a257wdTMN;i1PF3gXNn9QY*2WRzuiALLKGdw4^<H%{fbN3}EG{JcVE zF1dRaU)~2%2|66_l}q4H%c}Tv2AFvNAcj8`ev`}52(}pG44)8=_`|ulp9fSTlj(pM z;_T@*$%^pX1UW~8q9&$|>k;KZJP(Yy=-^I@rMjEJT8YganU~F-4R6j9Sa8x^O&Rt{ zyv<?a6Ni-=reTb5flo5ZWt6EUUFia31>~T2PA*HmR*F+p(XO%?G5d$S=PTx3@@MWA z(Ufi`?ymcwTczQtys1sNT?JFSj#d?(brT~>4HsJ0pF&p1f2W9#Tu9*f3+?3J=gaZz zw-l8$@bt%5_w1S9(j<pi`ARz3Urb#Gq3kP~sLGZ`gOL&`*UFP-oY$;9R32Ii>ac`# z<Zn{*u=kgG;4gPWW87*E->Md`(I>5!Te}B^jyu%um7t<6iugyHH8)|oZ}XF#g0qAy zs(KLOu1#gjsnBDxzRvKdXnl@j*)+<_2k&x~-SmC(8vsn01uCbuhjqTlGVYyeJcio2 zdr#kT%Q$FD9Nd6&9aUVR$<gtC>%6UcNHWC79%ajLO)TIbd(w)HpJ6bjWG8i8#=Y9Q zR5y));v*}^-A87yC^{o9_xQNvx$O^*eEHT~up-4mBHYz{^~K7ZYo;R4M*Q{?A4vr( zlkC2akgC6a5Ee+079BTRJ{w)6kkj4rmrIDqB>ZW@QMpmQ4saKDS>6wgq)<FnW>B)4 zLF(N~2*f{m7}v1vi)i@^LSFV$G?L-fG;~91R$xV(C0sd9TFT|zdL^~rK=)8{dKwU2 zz7)h8jI~Y+1?>V`rnXrL;nw*q9zeo#`?m$X9<;s$;;uK-mV6>Xcw$rIQ?_#zWMnws z{`&SqTL|UFZo@$<WjG`cJ6C?4rk=_EJ1E<>xX__fpZ;wR^O!Mz<v7f%z8Ig^@Q@d{ z!DTnjw1p}bMy<Ugu1gq4mGka^rWb5O0|!gS7rAg<POX}|YHT<`M}U%MeV{!d)fm4? znl9kYw7u$)P*Y>y(tOe{Qbn`&IORJh)bHG4u^aIv^kt6k%JiKO%IV5~F{mzH+i9lu z^(^YT@=u+9vZlHZSda_pXMBDbnzt5Vc=F3W;2K8UXmw8s?%-G*6V*L{30zFWiZ7QO zWHu9^`ZnrOH(7%na}r4U%+c;-Zg5)lAQ|)nsWV+opftSU(1)jL&nWqp*TjW>WB)kn zxBb4;jTaKLq7YCRb2WKqvp5+4HeMrwO2K<RU6e+jKa~RzM2td74fESWFK6?NZ`g9& z+JywI`Q?z4B=h3k=K3PvW8j63kgVQOTJwOUH*f!&C5Gc33R+-<dm2ZokM-$8M_irF zuldiqFj}6f`)a_YurzV1<`~7o1~O&_fsS_g=B!rb3b*ch#-sQ6=%n>{znDzw6^t)? z*^_1FZJUxQT8|<$Y8=~v!UQWCrr>y6rhwzLI0?r>wy@!{&Ur*l-WV`smcdyxTU0&$ zS1=aI(P*Vig_bmpM6L;7TwwmQSEy!e8_AY_*O-1WLvz^NM>WAGm{y$!YGEvomIo&O zwzBe4u*U^hXHSyz8{(^pZj?hdK^Bd&U;9w;*y~tVg9(y%(@i^-;sIgwdtH74$1&74 z*;9vhq<JTy(bsTCUOl%Yr({TJt_s%<y3=ZK=Q0+;Hl^c-&ndV^Yyvd)ILUl`<1!s< zd+)<Mn3bdwD2a&|xQzsH3L}jH9~XK|fOS|G%H;&fu#iPZDmRTl=Im{i!sLw9Y83}U zJ2tpS1{V`|c9~83TV&QoM}e^lr8&_*XUJhQtE&|YYXVmPb{{YH1~|2o#)+e+LHRQN zo}Oke0$JlH>ZeA;5nfIDBrmil14}yS+LV?KA17eyZ5MYho9hwK<bOvR=UTC&<;xN! zH#j0m<qw)-W*NUSj`>+c{|N4uzZ+Ql#54+K+X%IIiy&L6WY(IUZvIKE5kj~AG@mRJ z6>>Y$G9`ksQEcl600quxkOl-&`_q2#luqeVw$v#djnm%!Fv6pxIwVqt-re{+=7ET9 z)N<e(Xw*}rjyVIGn!_w?Xak3UCW;}g3G3SUH<iv7=tPxDzTRzIY~PmJ_i}Pf*LZp) zmH$|z*2U$RtS&b*zbO_J@FB5j!?2ROLGU-xHCAPMNsANV+1+o+QtOyy=5;?U70m{* z)8^URX4Ga#GW6ir-3WFs`k#;mT@2a_u0hY(IQ`oFqu(mbwW=rLjPMd+jKtil-1X}# zu(J9r;W!fmkFKA~jb15$jqsxs_3mq%AW@x9z8d$hRi1z@nQPrE;@)h*Zk{&uCw#Mp z>nQ64)b*?Iyvuk|)C3Y$1+yK(VA#g~pG$Z!Nd|wcXdSEM--g3-T8jDId3w$u50~@6 za*2&C=0>5;)s+_w&_=`ob~KJ{Pt@LPXfS0aohRd<MacWq8NNkmq#;c_H=mE1$HSr$ z{$FOfy1ECt;w-bcCDE?~NaCMTNg9uYcTOh@3OZi4yU6xECqCzz9}A)ib)LfI>DN+) z#PS89tSc*Y#g)J&h$ZHXLk4x0Zsm2USEvqze!okGoal&S$}&IUMbd|SLQfnp5!cEj z`E8B%eDh7!oZOhHFH87|zNCUP{GR+pr`L5TRKonUu<)J4>|D!f0J6LkL`ee?;hLvA zZ1gJ7D`BZk>q&almj_)a*<pd=H^c+L-byVDeTC1!XT&C#iQBLn*#X_fQeXAj0Y)uL zv2{)=tSt`J^scxnUP}plBBjV8Vdrz?^yZcW*!N|R$D6nu)fn$ipJ47Fh_8e`J+FT2 zGf;XD*bO3HS`bJVLv8mDifOt}We8-d+G2B=>SKt5^HF;*(}j>jxy_stcoB4|J{DRP z^QoG~F`BFH*5cg{XcSJ>xyZJO_*egNvkCK-8d(eKeEFUfK>K>o(Gzd^&6t_q*zZA; z#e}?k!%gmmbuT7b&tz>t_Qi-W<iMp!jz<%X`}9eoA#G)<=ki~lgSH8wM&!;9?5f=x zjg>g_XwY*Yv&Qg>E52l2n`QE8hlrKn)y%(#S(5`Ht1c?YVE8$)1KZb_i6nck_ql;l zsSNJ;+Cpl5wiPmQg=byJ>Sx+egC#<Mo4<Z2b(0C{dzk6GPjJTOAgj=T#~4H<cm%k2 zw12?8m}T1s3cG)^6Ar676V!gKK<qQqm;^><D|dL9e2#Qf+fQj*fYH_uZJM{q2hSaR zz!qZsl8r!q{Nl4RbWvsaRM{?o@&Z$)6+W2x&3Bky1BTzsP1|k9@`I{QBOa<jftd)g zg__k1idDlG(#vXtxA?R|P{BVKf?r8@vZ^hkyskuXL2tIE$@yvi0WA{2WRt>(?lZqI z5c%g8H+(}+C430+jCthSRYZy@K*%g-K;h+}<G55GhD%E*`&M^LQm(kA{{`p`T_IgH z>~8*m9v1SpLg(Cm#BWg1^>JQe*z2x>&fxo}Rp*Z<noUN7PUksmUoM}Ta8{NKYdtos z+<gOq46=jPoyR-u&l+bp`R=)>kUF1Sx22ck>77E7N0m^u=>`)hI9I{~Ml%)$F8fa7 z-*yR)Z#woOh|7_Iw*=@LZV{5BQ)lxt-@&Ie4yLqZcluYLmV+|16tC*L^ao^V-Y-$P zoBE^GQmB-{=$SJDRVd*B3+fV5Jzu`?!?0r<>b+hZv|z$o1d0pt+m9P(`>nc2$<=0$ z1Gd@}l2c^%B}v>E(ZO+hS`VijbH73g0#x$ay?Z;j(1}M1Q<>~!!e?g`7U%G2s>?;L zRlhVWWDs4TT_8pq_v)QJ3D91`H8j12Pq@PBc0c4rmwcuBGrIKKYjxAKnEbIrK;6n! zSZF~E6%YC&^#3-l|BEuZ3bH-_sEn_jH2|QX!1SMK9e4mX6bu0BpZ-5d3<dWe)c(gw z{+Ap7;|%{>1O1QVK>xpbyJ*<|)c-U5PssmU|HtS5BK*GrAOryHKZTu>gB>d6zZ~kH l1EBbSbq;oRsN(-RLLdMDbn$;3Y5#2n^S^xkKi&Yq{{a{t9hm?C literal 0 HcmV?d00001 From df11c9906ebd7e374724d59ff928e01a9db70dda Mon Sep 17 00:00:00 2001 From: bytestream <kieran@supportpal.com> Date: Wed, 15 Apr 2026 15:17:22 +0100 Subject: [PATCH 19/22] remove useless h1 --- _layouts/default.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/_layouts/default.html b/_layouts/default.html index 91407f5..bfcef2a 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -76,11 +76,9 @@ </head> <body> <header> - <h1> - <a href="{{ site.baseurl }}/" aria-label="{{ site.title }}"> - <img class="site-logo" src="{{ site.baseurl }}/assets/jquery-validation-logo.webp" alt="jQuery Validation Plugin"> - </a> - </h1> + <a href="{{ site.baseurl }}/" aria-label="{{ site.title }}"> + <img class="site-logo" src="{{ site.baseurl }}/assets/jquery-validation-logo.webp" alt="jQuery Validation Plugin"> + </a> <nav> <a href="{{ site.baseurl }}/">Home</a> <a href="{{ site.baseurl }}/documentation/">Documentation</a> From 409216a388db35877840f9af0f436c1ad000d172 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 14:23:29 +0000 Subject: [PATCH 20/22] Fix type annotations in validate.md - replace Any with specific types Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/20cc6850-ea77-41ca-9390-971b0d581239 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- _entries/validate.md | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/_entries/validate.md b/_entries/validate.md index 17fcbbe..ff54782 100644 --- a/_entries/validate.md +++ b/_entries/validate.md @@ -19,11 +19,11 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **options** *(Object)* (optional) - **debug** *(Any)* (default: `false`) + **debug** *(Boolean)* (default: `false`) Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a `window.console` property exists). Try to enable when a form is just submitted instead of validation stopping the submit. Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages. $("#myform").validate({ debug: true }); - **submitHandler** *(Any)* (default: `native form submit`) + **submitHandler** *(Function)* (default: `native form submit`) Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. Example: Submits the form via Ajax, using [jQuery Form plugin](http://jquery.malsup.com/form), when valid. $("#myform").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); } }); Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again. $("#myform").validate({ submitHandler: function(form) { // do other things for a valid form form.submit(); } }); The callback gets passed two arguments: @@ -35,7 +35,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The submit event instance. - **invalidHandler** *(Any)* + **invalidHandler** *(Function)* Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form. $("#myform").validate({ invalidHandler: function(event, validator) { // 'this' refers to the form var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } } }); The callback gets passed two arguments: @@ -47,31 +47,31 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The validator instance for the current form. - **ignore** *(Any)* (default: `":hidden"`) + **ignore** *(Selector)* (default: `":hidden"`) Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. Example: Ignores all elements with the class "ignore" when validating. $("#myform").validate({ ignore: ".ignore" }); - **rules** *(Any)* (default: `rules are read from markup (classes, attributes, data)`) + **rules** *(Object)* (default: `rules are read from markup (classes, attributes, data)`) Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). $("#myform").validate({ rules: { // simple rule, converted to {required:true} name: "required", // compound rule email: { required: true, email: true } } }); Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email. $("#myform").validate({ rules: { contact: { required: true, email: { depends: function(element) { return $("#contactform_email").is(":checked"); } } } } }); Example: Configure a rule that requires a parameter, along with a `depends` callback. $("#myform").validate({ rules: { // at least 15€ when bonus material is included pay_what_you_want: { required: true min: { // min needs a parameter passed to it param: 15, depends: function(element) { return $("#bonus-material").is(":checked"); } } } } }); - **messages** *(Any)* (default: `the default message for the method used`) + **messages** *(Object)* (default: `the default message for the method used`) Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email. $("#myform").validate({ rules: { name: "required", email: { required: true, email: true } }, messages: { name: "Please specify your name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" } } }); Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places. $("#myform").validate({ rules: { name: { required: true, minlength: 2 } }, messages: { name: { required: "We need your email address to contact you", minlength: jQuery.validator.format("At least {0} characters required!") } } }); - **groups** *(Any)* + **groups** *(Object)* Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messags in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); - **normalizer** *(Any)* + **normalizer** *(Function)* Prepares/transforms the elements value for validation. See [normalizer docs](/normalizer/) for more details. - **onsubmit** *(Any)* (default: `true`) + **onsubmit** *(Boolean)* (default: `true`) Validate the form on submit. Set to false to use only other events for validation. Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise). $("#myform").validate({ onsubmit: false }); - **onfocusout** *(Any)* + **onfocusout** *(Boolean | Function)* Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables focusout validation. $("#myform").validate({ onfocusout: false }); The callback gets passed two arguments: @@ -83,7 +83,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The event object for this focusout event. - **onkeyup** *(Any)* + **onkeyup** *(Boolean | Function)* Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onkeyup validation. $("#myform").validate({ onkeyup: false }); The callback gets passed two arguments: @@ -95,7 +95,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The event object for this keyup event. - **onclick** *(Any)* + **onclick** *(Boolean | Function)* Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onclick validation of checkboxes, radio buttons, and select elements. $("#myform").validate({ onclick: false }); The callback gets passed two arguments: @@ -107,39 +107,39 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The event object for this click event. - **focusInvalid** *(Any)* (default: `true`) + **focusInvalid** *(Boolean)* (default: `true`) Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. Example: Disables focusing of invalid elements. $("#myform").validate({ focusInvalid: false }); - **focusCleanup** *(Any)* (default: `false`) + **focusCleanup** *(Boolean)* (default: `false`) If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused. $("#myform").validate({ focusCleanup: true }); - **errorClass** *(Any)* (default: `"error"`) + **errorClass** *(String)* (default: `"error"`) Use this class to create error labels, to look for existing error labels and to add it to invalid elements. Example: Sets the error class to "invalid". $("#myform").validate({ errorClass: "invalid" }); - **validClass** *(Any)* (default: `"valid"`) + **validClass** *(String)* (default: `"valid"`) This class is added to an element after it was validated and considered valid. Example: Sets the valid class to "success". $("#myform").validate({ validClass: "success" }); - **errorElement** *(Any)* (default: `"label"`) + **errorElement** *(String)* (default: `"label"`) Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). Example: Sets the error element to "em". $("#myform").validate({ errorElement: "em" }); - **wrapper** *(Any)* (default: `window`) + **wrapper** *(String)* (default: `window`) Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container. $("#myform").validate({ wrapper: "li" }); - **errorLabelContainer** *(Any)* + **errorLabelContainer** *(Selector)* Hide and show this container when validating. Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages. $("#myform").validate({ errorLabelContainer: "#messageBox", wrapper: "li", submitHandler: function() { alert("Submitted!") } }); - **errorContainer** *(Any)* + **errorContainer** *(Selector)* Hide and show this container when validating. Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option). $("#myform").validate({ errorContainer: "#messageBox1, #messageBox2", errorLabelContainer: "#messageBox1 ul", wrapper: "li", debug:true, submitHandler: function() { alert("Submitted!") } }); - **showErrors** *(Any)* + **showErrors** *(Function)* A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display. $("#myform").validate({ showErrors: function(errorMap, errorList) { $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); this.defaultShowErrors(); } }); The callback gets passed two arguments: @@ -159,7 +159,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The DOMElement for this entry. - **errorPlacement** *(Any)* (default: `Places the error label after the invalid element`) + **errorPlacement** *(Function)* (default: `Places the error label after the invalid element`) Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ errorPlacement: function(error, element) { error.appendTo( element.parent("td").next("td") ); } }); The callback gets passed two arguments: @@ -171,7 +171,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The validated input, for relative positioning. - **success** *(Any)* + **success** *(String | Function)* If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". Example: Add a class "valid" to valid elements, styled via CSS. $("#myform").validate({ success: "valid", submitHandler: function() { alert("Submitted!") } }); Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!". $("#myform").validate({ success: function(label) { label.addClass("valid").text("Ok!") }, submitHandler: function() { alert("Submitted!") } }); The callback gets passed two arguments: @@ -183,7 +183,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t The element currently being validated, as a DOMElement. - **highlight** *(Any)* (default: `Adds errorClass (see the option) to the element`) + **highlight** *(Function)* (default: `Adds errorClass (see the option) to the element`) How to highlight invalid fields. Override to decide which fields and how to highlight. Example: Highlights an invalid element by fading it out and in again. $("#myform").validate({ highlight: function(element, errorClass) { $(element).fadeOut(function() { $(element).fadeIn(); }); } }); Example: Adds the error class to both the invalid element and its label $("#myform").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.id + "]") .addClass(errorClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.id + "]") .removeClass(errorClass); } }); The callback gets passed three arguments: @@ -199,10 +199,10 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t Current value of the `validClass` option. - **unhighlight** *(Any)* (default: `Removes the errorClass`) + **unhighlight** *(Function)* (default: `Removes the errorClass`) Called to revert changes made by option highlight, same arguments as highlight. - **ignoreTitle** *(Any)* (default: `false`) + **ignoreTitle** *(Boolean)* (default: `false`) Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); From fad78dca31f8e159e42716c4d6273cb27a4160bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 14:27:44 +0000 Subject: [PATCH 21/22] Fix typos and formatting issues in documentation Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/8bc572b0-b97a-4158-8713-9aa7a99fa1a8 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- _entries/required-method.md | 2 +- _entries/validate.md | 4 ++-- index.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_entries/required-method.md b/_entries/required-method.md index 8734bb5..e6c6cbb 100644 --- a/_entries/required-method.md +++ b/_entries/required-method.md @@ -13,7 +13,7 @@ Makes the element required. ## Description -Return false, if the element is empty (text input) or unchecked (radio/checkbox) or if nothing is selected (select). Works with text inputs, selects, checkboxes and radio buttons. To force a user to select an option from a select box, provide an empty option element like <option value="">Choose...</option> Note that white spaces are considered valid. +Return false, if the element is empty (text input) or unchecked (radio/checkbox) or if nothing is selected (select). Works with text inputs, selects, checkboxes and radio buttons. To force a user to select an option from a select box, provide an empty option element like `<option value="">Choose...</option>`. Note that white spaces are considered valid. ## Usage diff --git a/_entries/validate.md b/_entries/validate.md index ff54782..1e153ec 100644 --- a/_entries/validate.md +++ b/_entries/validate.md @@ -61,7 +61,7 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **groups** *(Object)* - Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messags in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); + Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); **normalizer** *(Function)* @@ -205,4 +205,4 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **ignoreTitle** *(Boolean)* (default: `false`) - Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compability, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); + Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compatibility, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); diff --git a/index.md b/index.md index 7d0dfa7..d5576c3 100644 --- a/index.md +++ b/index.md @@ -3,7 +3,7 @@ layout: default title: jQuery Validation Plugin --- -This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you're building something new from scratch, but also when you're trying to integrate something into an existing application with lots of existing markup. The plugin comes bundled with a useful set of validation methods, including URL and email validation, while providing an API to write your own methods. All bundled methods come with default error messages in english and translations into 37 other languages. +This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you're building something new from scratch, but also when you're trying to integrate something into an existing application with lots of existing markup. The plugin comes bundled with a useful set of validation methods, including URL and email validation, while providing an API to write your own methods. All bundled methods come with default error messages in English and translations into 37 other languages. For a quick overview of what this plugin provides, check out this [Webucator](https://www.webucator.com/) video (they also provide [jQuery trainings](https://www.webucator.com/webdesign/jquery.cfm)): From 0eaf33ab014e3abf3c2b76fabbdd2e6978bdb01f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 14:56:36 +0000 Subject: [PATCH 22/22] Fix validate.md formatting: add line breaks, code blocks, and fix syntax errors Agent-Logs-Url: https://github.com/jquery-validation/validation-content/sessions/0436e5d0-b9c5-4ceb-874b-044476769828 Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com> --- _entries/validate.md | 413 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 389 insertions(+), 24 deletions(-) diff --git a/_entries/validate.md b/_entries/validate.md index 1e153ec..15a0b53 100644 --- a/_entries/validate.md +++ b/_entries/validate.md @@ -21,11 +21,42 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **debug** *(Boolean)* (default: `false`) - Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a `window.console` property exists). Try to enable when a form is just submitted instead of validation stopping the submit. Example: Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages. $("#myform").validate({ debug: true }); + Enables debug mode. If true, the form is not submitted and certain errors are displayed on the console (will check if a `window.console` property exists). Try to enable when a form is just submitted instead of validation stopping the submit. + + **Example:** Prevents the form from submitting and tries to help setting up the validation with warnings about missing methods and other debug messages. + + ```javascript + $("#myform").validate({ + debug: true + }); + ``` **submitHandler** *(Function)* (default: `native form submit`) - Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. Example: Submits the form via Ajax, using [jQuery Form plugin](http://jquery.malsup.com/form), when valid. $("#myform").validate({ submitHandler: function(form) { $(form).ajaxSubmit(); } }); Example: Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again. $("#myform").validate({ submitHandler: function(form) { // do other things for a valid form form.submit(); } }); The callback gets passed two arguments: + Callback for handling the actual submit when the form is valid. Gets the form and the submit event as the only arguments. Replaces the default submit. The right place to submit a form via Ajax after it is validated. + + **Example:** Submits the form via Ajax, using [jQuery Form plugin](http://jquery.malsup.com/form), when valid. + + ```javascript + $("#myform").validate({ + submitHandler: function(form) { + $(form).ajaxSubmit(); + } + }); + ``` + + **Example:** Use submitHandler to process something and then using the default submit. Note that "form" refers to a DOM element, this way the validation isn't triggered again. + + ```javascript + $("#myform").validate({ + submitHandler: function(form) { + // do other things for a valid form + form.submit(); + } + }); + ``` + + The callback gets passed two arguments: **form** *(Element)* @@ -37,7 +68,29 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **invalidHandler** *(Function)* - Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. Example: Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form. $("#myform").validate({ invalidHandler: function(event, validator) { // 'this' refers to the form var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } } }); The callback gets passed two arguments: + Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second. + + **Example:** Displays a message above the form, indicating how many fields are invalid when the user tries to submit an invalid form. + + ```javascript + $("#myform").validate({ + invalidHandler: function(event, validator) { + // 'this' refers to the form + var errors = validator.numberOfInvalids(); + if (errors) { + var message = errors == 1 + ? 'You missed 1 field. It has been highlighted' + : 'You missed ' + errors + ' fields. They have been highlighted'; + $("div.error span").html(message); + $("div.error").show(); + } else { + $("div.error").hide(); + } + } + }); + ``` + + The callback gets passed two arguments: **event** *(Event)* @@ -49,19 +102,137 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **ignore** *(Selector)* (default: `":hidden"`) - Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. Example: Ignores all elements with the class "ignore" when validating. $("#myform").validate({ ignore: ".ignore" }); + Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements. + + **Example:** Ignores all elements with the class "ignore" when validating. + + ```javascript + $("#myform").validate({ + ignore: ".ignore" + }); + ``` **rules** *(Object)* (default: `rules are read from markup (classes, attributes, data)`) - Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. Example: Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). $("#myform").validate({ rules: { // simple rule, converted to {required:true} name: "required", // compound rule email: { required: true, email: true } } }); Example: Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email. $("#myform").validate({ rules: { contact: { required: true, email: { depends: function(element) { return $("#contactform_email").is(":checked"); } } } } }); Example: Configure a rule that requires a parameter, along with a `depends` callback. $("#myform").validate({ rules: { // at least 15€ when bonus material is included pay_what_you_want: { required: true min: { // min needs a parameter passed to it param: 15, depends: function(element) { return $("#bonus-material").is(":checked"); } } } } }); + Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String. Can be combined with class/attribute/data rules. Each rule can be specified as having a depends-property to apply the rule only in certain conditions. See the second example below for details. + + **Example:** Specifies a name element as required and an email element as required (using the shortcut for a single rule) and a valid email address (using another object literal). + + ```javascript + $("#myform").validate({ + rules: { + // simple rule, converted to {required:true} + name: "required", + // compound rule + email: { + required: true, + email: true + } + } + }); + ``` + + **Example:** Specifies a contact element as required and as email address, the latter depending on a checkbox being checked for contact via email. + + ```javascript + $("#myform").validate({ + rules: { + contact: { + required: true, + email: { + depends: function(element) { + return $("#contactform_email").is(":checked"); + } + } + } + } + }); + ``` + + **Example:** Configure a rule that requires a parameter, along with a `depends` callback. + + ```javascript + $("#myform").validate({ + rules: { + // at least 15€ when bonus material is included + pay_what_you_want: { + required: true, + min: { + // min needs a parameter passed to it + param: 15, + depends: function(element) { + return $("#bonus-material").is(":checked"); + } + } + } + } + }); + ``` **messages** *(Object)* (default: `the default message for the method used`) - Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. Example: Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email. $("#myform").validate({ rules: { name: "required", email: { required: true, email: true } }, messages: { name: "Please specify your name", email: { required: "We need your email address to contact you", email: "Your email address must be in the format of name@domain.com" } } }); Example: Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places. $("#myform").validate({ rules: { name: { required: true, minlength: 2 } }, messages: { name: { required: "We need your email address to contact you", minlength: jQuery.validator.format("At least {0} characters required!") } } }); + Key/value pairs defining custom messages. Key is the name of an element, value the message to display for that element. Instead of a plain message, another map with specific messages for each rule can be used. Overrides the title attribute of an element or the default message for the method (in that order). Each message can be a String or a Callback. The callback is called in the scope of the validator, with the rule's parameters as the first argument and the element as the second, and must return a String to display as the message. + + **Example:** Specifies a name element as required and an email element as required and a valid email address. A single message is specified for the name element, and two messages for email. + + ```javascript + $("#myform").validate({ + rules: { + name: "required", + email: { + required: true, + email: true + } + }, + messages: { + name: "Please specify your name", + email: { + required: "We need your email address to contact you", + email: "Your email address must be in the format of name@domain.com" + } + } + }); + ``` + + **Example:** Validates the name-field as required and having at least two characters. Provides a callback message using jQuery.validator.format to avoid having to specify the parameter in two places. + + ```javascript + $("#myform").validate({ + rules: { + name: { + required: true, + minlength: 2 + } + }, + messages: { + name: { + required: "We need your email address to contact you", + minlength: jQuery.validator.format("At least {0} characters required!") + } + } + }); + ``` **groups** *(Object)* - Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ groups: { username: "fname lname" }, errorPlacement: function(error, element) { if (element.attr("name") == "fname" || element.attr("name") == "lname" ) { error.insertAfter("#lastname"); } else { error.insertAfter(element); } } }); + Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space separated list of element names as the value. Use errorPlacement to control where the group message is placed. + + **Example:** Use a table layout for the form, placing error messages in the next cell after the input. + + ```javascript + $("#myform").validate({ + groups: { + username: "fname lname" + }, + errorPlacement: function(error, element) { + if (element.attr("name") == "fname" || element.attr("name") == "lname") { + error.insertAfter("#lastname"); + } else { + error.insertAfter(element); + } + } + }); + ``` **normalizer** *(Function)* @@ -69,11 +240,29 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **onsubmit** *(Boolean)* (default: `true`) - Validate the form on submit. Set to false to use only other events for validation. Example: Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise). $("#myform").validate({ onsubmit: false }); + Validate the form on submit. Set to false to use only other events for validation. + + **Example:** Disables onsubmit validation, allowing the user to submit whatever he wants, while still validating on keyup/blur/click events (if not specified otherwise). + + ```javascript + $("#myform").validate({ + onsubmit: false + }); + ``` **onfocusout** *(Boolean | Function)* - Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables focusout validation. $("#myform").validate({ onfocusout: false }); The callback gets passed two arguments: + Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. + + **Example:** Disables focusout validation. + + ```javascript + $("#myform").validate({ + onfocusout: false + }); + ``` + + The callback gets passed two arguments: **element** *(Element)* @@ -85,7 +274,17 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **onkeyup** *(Boolean | Function)* - Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onkeyup validation. $("#myform").validate({ onkeyup: false }); The callback gets passed two arguments: + Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. + + **Example:** Disables onkeyup validation. + + ```javascript + $("#myform").validate({ + onkeyup: false + }); + ``` + + The callback gets passed two arguments: **element** *(Element)* @@ -97,7 +296,17 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **onclick** *(Boolean | Function)* - Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. Example: Disables onclick validation of checkboxes, radio buttons, and select elements. $("#myform").validate({ onclick: false }); The callback gets passed two arguments: + Validate checkboxes, radio buttons, and select elements on click. Set to false to disable. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. + + **Example:** Disables onclick validation of checkboxes, radio buttons, and select elements. + + ```javascript + $("#myform").validate({ + onclick: false + }); + ``` + + The callback gets passed two arguments: **element** *(Element)* @@ -109,39 +318,122 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **focusInvalid** *(Boolean)* (default: `true`) - Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. Example: Disables focusing of invalid elements. $("#myform").validate({ focusInvalid: false }); + Focus the last active or first invalid element on submit via validator.focusInvalid(). The last active element is the one that had focus when the form was submitted, avoiding stealing its focus. If there was no element focused, the first one in the form gets it, unless this option is turned off. + + **Example:** Disables focusing of invalid elements. + + ```javascript + $("#myform").validate({ + focusInvalid: false + }); + ``` **focusCleanup** *(Boolean)* (default: `false`) - If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. Example: Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused. $("#myform").validate({ focusCleanup: true }); + If enabled, removes the errorClass from the invalid elements and hides all error messages whenever the element is focused. Avoid combination with focusInvalid. + + **Example:** Enables cleanup when focusing elements, removing the error class and hiding error messages when an element is focused. + + ```javascript + $("#myform").validate({ + focusCleanup: true + }); + ``` **errorClass** *(String)* (default: `"error"`) - Use this class to create error labels, to look for existing error labels and to add it to invalid elements. Example: Sets the error class to "invalid". $("#myform").validate({ errorClass: "invalid" }); + Use this class to create error labels, to look for existing error labels and to add it to invalid elements. + + **Example:** Sets the error class to "invalid". + + ```javascript + $("#myform").validate({ + errorClass: "invalid" + }); + ``` **validClass** *(String)* (default: `"valid"`) - This class is added to an element after it was validated and considered valid. Example: Sets the valid class to "success". $("#myform").validate({ validClass: "success" }); + This class is added to an element after it was validated and considered valid. + + **Example:** Sets the valid class to "success". + + ```javascript + $("#myform").validate({ + validClass: "success" + }); + ``` **errorElement** *(String)* (default: `"label"`) - Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). Example: Sets the error element to "em". $("#myform").validate({ errorElement: "em" }); + Use this element type to create error messages and to look for existing error messages. The default, "label", has the advantage of creating a meaningful link between error message and invalid field using the for attribute (which is always used, regardless of element type). + + **Example:** Sets the error element to "em". + + ```javascript + $("#myform").validate({ + errorElement: "em" + }); + ``` **wrapper** *(String)* (default: `window`) - Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. Example: Wrap each error element with a list item, useful when using an ordered or unordered list as the error container. $("#myform").validate({ wrapper: "li" }); + Wrap error labels with the specified element. Useful in combination with errorLabelContainer to create a list of error messages. + + **Example:** Wrap each error element with a list item, useful when using an ordered or unordered list as the error container. + + ```javascript + $("#myform").validate({ + wrapper: "li" + }); + ``` **errorLabelContainer** *(Selector)* - Hide and show this container when validating. Example: All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages. $("#myform").validate({ errorLabelContainer: "#messageBox", wrapper: "li", submitHandler: function() { alert("Submitted!") } }); + Hide and show this container when validating. + + **Example:** All error labels are displayed inside an unordered list with the ID "messageBox", as specified by the selector passed as errorContainer option. All error elements are wrapped inside a li element, to create a list of messages. + + ```javascript + $("#myform").validate({ + errorLabelContainer: "#messageBox", + wrapper: "li", + submitHandler: function() { alert("Submitted!") } + }); + ``` **errorContainer** *(Selector)* - Hide and show this container when validating. Example: Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option). $("#myform").validate({ errorContainer: "#messageBox1, #messageBox2", errorLabelContainer: "#messageBox1 ul", wrapper: "li", debug:true, submitHandler: function() { alert("Submitted!") } }); + Hide and show this container when validating. + + **Example:** Uses an additonal container for error messages. The elements given as the errorContainer are all shown and hidden when errors occur. However, the error labels themselves are added to the element(s) given as errorLabelContainer, here an unordered list. Therefore the error labels are also wrapped into li elements (wrapper option). + + ```javascript + $("#myform").validate({ + errorContainer: "#messageBox1, #messageBox2", + errorLabelContainer: "#messageBox1 ul", + wrapper: "li", + debug:true, + submitHandler: function() { alert("Submitted!") } + }); + ``` **showErrors** *(Function)* - A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). Example: Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display. $("#myform").validate({ showErrors: function(errorMap, errorList) { $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); this.defaultShowErrors(); } }); The callback gets passed two arguments: + A custom message display handler. Gets the map of errors as the first argument and an array of errors as the second, called in the context of the validator object. The arguments contain only those elements currently validated, which can be a single element when doing validation on focusout or keyup. You can trigger (in addition to your own messages) the default behaviour by calling this.defaultShowErrors(). + + **Example:** Update the number of invalid elements each time an error is displayed. Delegates to the default implementation for the actual error display. + + ```javascript + $("#myform").validate({ + showErrors: function(errorMap, errorList) { + $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); + this.defaultShowErrors(); + } + }); + ``` + + The callback gets passed two arguments: **errorMap** *(Object)* @@ -161,7 +453,19 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **errorPlacement** *(Function)* (default: `Places the error label after the invalid element`) - Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. Example: Use a table layout for the form, placing error messages in the next cell after the input. $("#myform").validate({ errorPlacement: function(error, element) { error.appendTo( element.parent("td").next("td") ); } }); The callback gets passed two arguments: + Customize placement of created error labels. First argument: The created error label as a jQuery object. Second argument: The invalid element as a jQuery object. + + **Example:** Use a table layout for the form, placing error messages in the next cell after the input. + + ```javascript + $("#myform").validate({ + errorPlacement: function(error, element) { + error.appendTo( element.parent("td").next("td") ); + } + }); + ``` + + The callback gets passed two arguments: **error** *(jQuery)* @@ -173,7 +477,29 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **success** *(String | Function)* - If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". Example: Add a class "valid" to valid elements, styled via CSS. $("#myform").validate({ success: "valid", submitHandler: function() { alert("Submitted!") } }); Example: Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!". $("#myform").validate({ success: function(label) { label.addClass("valid").text("Ok!") }, submitHandler: function() { alert("Submitted!") } }); The callback gets passed two arguments: + If specified, the error label is displayed to show a valid element. If a String is given, it is added as a class to the label. If a Function is given, it is called with the label (as a jQuery object) and the validated input (as a DOM element). The label can be used to add a text like "ok!". + + **Example:** Add a class "valid" to valid elements, styled via CSS. + + ```javascript + $("#myform").validate({ + success: "valid", + submitHandler: function() { alert("Submitted!") } + }); + ``` + + **Example:** Add a class "valid" to valid elements, styled via CSS, and add the text "Ok!". + + ```javascript + $("#myform").validate({ + success: function(label) { + label.addClass("valid").text("Ok!") + }, + submitHandler: function() { alert("Submitted!") } + }); + ``` + + The callback gets passed two arguments: **label** *(jQuery)* @@ -185,7 +511,38 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **highlight** *(Function)* (default: `Adds errorClass (see the option) to the element`) - How to highlight invalid fields. Override to decide which fields and how to highlight. Example: Highlights an invalid element by fading it out and in again. $("#myform").validate({ highlight: function(element, errorClass) { $(element).fadeOut(function() { $(element).fadeIn(); }); } }); Example: Adds the error class to both the invalid element and its label $("#myform").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.id + "]") .addClass(errorClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.id + "]") .removeClass(errorClass); } }); The callback gets passed three arguments: + How to highlight invalid fields. Override to decide which fields and how to highlight. + + **Example:** Highlights an invalid element by fading it out and in again. + + ```javascript + $("#myform").validate({ + highlight: function(element, errorClass) { + $(element).fadeOut(function() { + $(element).fadeIn(); + }); + } + }); + ``` + + **Example:** Adds the error class to both the invalid element and its label + + ```javascript + $("#myform").validate({ + highlight: function(element, errorClass, validClass) { + $(element).addClass(errorClass).removeClass(validClass); + $(element.form).find("label[for=" + element.id + "]") + .addClass(errorClass); + }, + unhighlight: function(element, errorClass, validClass) { + $(element).removeClass(errorClass).addClass(validClass); + $(element.form).find("label[for=" + element.id + "]") + .removeClass(errorClass); + } + }); + ``` + + The callback gets passed three arguments: **element** *(Element)* @@ -205,4 +562,12 @@ This method sets up event handlers for submit, focus, keyup, blur and click to t **ignoreTitle** *(Boolean)* (default: `false`) - Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compatibility, the message-from-title is likely to be completely removed in a future release. Example: Configure the plugin to ignore title attributes on validated elements when looking for messages. $("#myform").validate({ ignoreTitle: true }); + Set to skip reading messages from the title attribute, helps to avoid issues with Google Toolbar; default is false for compatibility, the message-from-title is likely to be completely removed in a future release. + + **Example:** Configure the plugin to ignore title attributes on validated elements when looking for messages. + + ```javascript + $("#myform").validate({ + ignoreTitle: true + }); + ```