npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.formvalid

v1.0.4

Published

jQuery Form Validation Plugin

Downloads

7

Readme

formValid jQuery Plugin

Demo & Examples

https://mrygielski.github.io/jquery.formValid/

Usage

<form method="post" id="form">
	<div class="row">
		<div class="col-md-12">
			<input type="text" id="labelLogin" class="form-control" data-field="login">
			<label for="labelLogin">Login (email) *</label>
			<div class="valid-message"></div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<input type="password" id="labelPassword" class="form-control" data-field="password">
			<label for="labelSurname">Password *</label>
			<div class="valid-message"></div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<button class="btn btn-primary" type="submit">LOGIN</button>
		</div>
	</div>
</form>

Each field must have an attribute data-field.

Include jQuery:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Include plugin's CSS and JS:

<link rel="stylesheet" href="src/jquery.formValid.csss">
<script src="src/jquery.formValid.js"></script>

Call the plugin:

/* Init form fields */
var form = $('#form').formValid({
	fields: {
		"login": {
			"required": true, 
			"tests": [
				{
					"type": "null", 
					"message": "Not entered login"
				},
				{
					"type": "email", 
					"message": "Your email is incorrect"
				}
			]
		},
		"password": {
			"required": true,
			"tests": [
				{
					"type": "null", 
					"message": "Not entered password"
				}
			]
		}
	}
});

/* Validates the field after the change */
form.keypress(300);
$('button[type="submit"]').click(function() {
	// Validation test 	
	form.test();
	if (form.errors() == 0) {
		alert('Ok');
	}
	return false;
});

Options

Here's a list of available settings.

$('#form').formValid({
    fields: {
        "field_name": {
            "required": true,
            "tests": [
                {
                    "type": "null",
                    "message": "..."
                },
                ...
            ],
            "change": function() {
                ...
            }
        },
        ...
    }
});

Option fields is an array containing information about all fields. The first part of the array must have a name that matches the attribute data-field assigned to the field in the html code.

Field options:

Attribute | Type | Default | Description --- | --- | --- | --- required| boolean | false | Determines whether the field should be required when checking. Possible values: true, false tests| Array | - | Specifies a list of validation tests for the field. The table must be based on the type and message parameters. type specifies the type of test, message message that should appear when the field value fails the test. change| Method | - | It allows you to embed your own code that will be called when the field value changes.

Methods

Name | Return | Params | Description --- | --- | --- | --- test| - | - | Performs a validation test of all defined fields. keypress| - | timeout:Integer | Carries out a validation test for the modified field after a specific timeout value. errors| Number | - | Returns information in the form of a number if the form has validation errors.

Tests

Name | Description --- | --- null| Checks whether the value is empty. email| Checks the correctness of the email address. number| Checks whether the value is a number. letters| Checks whether the value is text. phone| Checks the correctness of the telephone number. postcode| Checks the correctness of the postal code (Poland).

You can also use the regex parameter instead of the test name, so you can define your own regex. Example:

"tests": [
	{
		"regex": "^[A-Z]+$", 
		"message": "Only upper-case letter"
	}
]

Installation

You can install jquery.formValid by using Bower.

bower install jquery.formValid

Or you can install it through npm:

npm install --save jquery.formvalid

Create distribution version

npm install
./gulp

Changelog

Version | Date | Change --- | --- | --- 1.0.1 |2018-04-28| Addition of own regex definitions

License

This plugin is available under the MIT license.