插件 jQuery.is.js 中文API文档

🌙
手机阅读
本文目录结构

插件 jQuery.is.js 中文API文档 https://github.com/rthor/isjs

is.js

Check your data against regular expressions or known keywords (see Keyword section). Different versions for different platforms are availible.

Currently these plugins are stable:

  • jQuery
  • Vanilla JavaScript
  • Node.js Module

I wrote a really short blog post about the project a while ago, which can be read at rthor.is/javascript/cross-plugin-javascript-project-isjs. Note that some code examples are out of date.

Keywords

cc (Credit cards)

Works for:

American Express

Discover

MasterCard

Visa

or any

// Example (vanilla JS)
is('0000000000000000', 'cc:any'); // Returns true
is('4000000000000000', 'cc:Visa'); // Returns true

datetime (Date and time)

Format: 1996-12-19T16:39:57-08:00

// Example (vanilla JS)
is('1996-12-19T16:39:57-08:00', 'datetime'); // Returns true

isbn (ISBN)

ISBN 10

// Example (vanilla JS)
is('0-85131-041-9', 'isbn'); // Returns true
is('0851310419', 'isbn'); // Returns true

ISBN 13

// Example (vanilla JS)
is('978-1-56619-909-4', 'isbn'); // Returns true
is('9781566199094', 'isbn'); // Returns true

latlng (Latitude and longitude)

Latitude

// Example (vanilla JS)
is('64.163296', 'latlng'); // Returns true

Longitude

// Example (vanilla JS)
is('-21.859328', 'latlng'); // Returns true

phone (Phone numbers)

Argentina (ar)

Australia (au)

France (fr)

Iceland (is)

United Kingdom (uk)

United States of America (us)

// Example (vanilla JS)
is('+354 000-0000', 'phone:is'); // Returns true
is('000-0000', 'phone:is'); // Returns true
is('0000000', 'phone:is'); // Returns true

zip:’two letter ISO 3166 country code’ (Zip codes for countries)

Argentina (ar)

Australia (au)

Austria (at)

Belgium (be)

Brazil (br)

Bulgaria (bg)

Canada (ca)

Croatia (hr)

Cyprus (cy)

Czech Republic (cz)

Denmark (dk)

Estonia (ee)

Finland (fi)

France (fr)

Germany (de)

Great Britain (gb)

Greece (gr)

Hungary (hu)

Iceland (is)

Italy (it)

Japan (jp)

Latvia (lv)

Lithuania (lt)

Luxembourg (lu)

Malta (mt)

Netherlands (nl)

Norway (no)

Poland (pl)

Portugal (pt)

Romania (ro)

Slovakia (sk)

Slovenia (se)

Spain (es)

Sweden (se)

Turkey (tr)

Ukraine (ua)

United States of America (us)

// Example (vanilla JS)
is('112', 'zip:is'); // Returns true
is('32044', 'zip:us'); // Returns true

Additional Goodies

The second parameter can point to a function within the check.fn object. It can also be a regular user defined function accepting a single argument which can be used for some complex (or simple) validation.

// Example (vanilla JS)
is(42, function ( num ) {
	return num === 20; // returns false
});

The expression argument can be an actual regular expression.

// Example (vanilla JS)
is('love', /.+/); // returns true

Change Log

0.2.1 AUGUST 3, 2013

  • Add a Luhn algorithm as a check function. Thanks everyone who pointed out the need for it.

  • Fix the README.

  • Rename the regex obj to check. It just makes more sense since we now have function tests.

0.2.0 JULY 30, 2013

  • All regular expressions are unit tested.

  • Added functionality to validate via functions. The second argument can now either be a regular function accepting a single argument or a string pointing to a function within the regex.fn object.

  • Current functions include: even, odd, regexp, ok and function.

0.1.2 JUNE 14, 2013

  • phone has become an object so calling it requires a two letter ISO 3166 country code. For example validating Icelandic phone numbers in vanilla JS is now done thusly: is('+354 000-0000', 'phone:is'). In addition a few more countries were added.

  • cc - pretty much same thing happend as with the phone thing.

0.1.1 May 24, 2013

  • First stable release

Get in touch

Follow me on twitter @rthor or send me a line in an email.

AXIHE / 精选资源

浏览全部教程

面试题

学习网站

前端培训
自己甄别

前端书籍

关于朱安邦

我叫 朱安邦,阿西河的站长,在杭州。

以前是一名平面设计师,后来开始接接触前端开发,主要研究前端技术中的JS方向。

业余时间我喜欢分享和交流自己的技术,欢迎大家关注我的 Bilibili

关注我: Github / 知乎

于2021年离开前端领域,目前重心放在研究区块链上面了

我叫朱安邦,阿西河的站长

目前在杭州从事区块链周边的开发工作,机械专业,以前从事平面设计工作。

2014年底脱产在老家自学6个月的前端技术,自学期间几乎从未出过家门,最终找到了满意的前端工作。更多>

于2021年离开前端领域,目前从事区块链方面工作了