Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery-validity

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-validity

Form validation jQuery plugin

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

jQuery Validity

A form validation jQuery plugin written in late 2015 (whatever that means).

This is heavily inspired by the Abide library (from the Zurb Foundation framework), but implemented completely from scratch and as a jQuery plugin, npm-ready and most of all not bloated.

Install

Using npm:

npm install jquery-validity

Browserify and others:

var $ = require('jquery')
require('jquery-validity')($)

ES2015 modules:

import $ from 'jquery'
import validity from 'jquery-validity'

validity($)

Usage

$('.my-form').validity(options)

Options

There are the defaults:

$.fn.validity.defaults = {
  attributeName: 'data-validators',
  errorClass: 'error',
  focusOnFirstError: true,
  onSubmit: null,
  parentSelector: 'p',
  requiredMessage: 'This field is required',
  timeout: 1000, // if `false`, no "live" validation
  validateOnBlur: true,
  validators: {}
}

Events

$form.on('validity.invalid', {
  fields,
  firstErrorField,
  form,
  submitEvent // original submit event
})

$form.on('validity.valid', {
  form,
  submitEvent
})

(TODO)

An example of an email validator function:

function emailValidator (message) {
  // A `validator` is a function that receives a `value`
  // and should return `null` if valid, or a message if not
  return function (value) {
    if (validator.isEmail(value)) {
      return null
    }
    return message
  }
}

TODO

  • Proper tests
  • Finish documentation
  • A better usage guide and examples

License

MIT

Keywords

FAQs

Package last updated on 18 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc