├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTORS.md
├── Gruntfile.js
├── LICENSE.txt
├── README.md
├── bootstrapValidator.jquery.json
├── bower.json
├── demo
├── ajaxSubmit.html
├── ajaxSubmit.php
├── attribute.html
├── choice.html
├── collapse.html
├── container.html
├── container2.html
├── container3.html
├── container4.html
├── date.html
├── defaultMessage.html
├── dynamic.html
├── dynamic2.html
├── dynamic3.html
├── dynamic4.html
├── enable.html
├── enable2.html
├── event.html
├── event2.html
├── event3.html
├── feedbackIcons.html
├── file.html
├── group.html
├── html5.html
├── i18n.html
├── index.html
├── invisible.html
├── message.html
├── multiple.html
├── remote.html
├── remote.php
├── remote2.php
├── reset.html
├── selector.html
├── selector2.html
├── specialName.html
├── submitHandler.html
├── tab.html
├── target.php
├── tooltip.html
└── validators.html
├── dist
├── css
│ ├── bootstrapValidator.css
│ └── bootstrapValidator.min.css
└── js
│ ├── bootstrapValidator.js
│ ├── bootstrapValidator.min.js
│ └── language
│ ├── ar_MA.js
│ ├── be_FR.js
│ ├── be_NL.js
│ ├── bg_BG.js
│ ├── cs_CZ.js
│ ├── da_DK.js
│ ├── de_DE.js
│ ├── en_US.js
│ ├── es_CL.js
│ ├── es_ES.js
│ ├── fa_IR.js
│ ├── fr_FR.js
│ ├── gr_EL.js
│ ├── he_IL.js
│ ├── hu_HU.js
│ ├── id_ID.js
│ ├── it_IT.js
│ ├── ja_JP.js
│ ├── nl_NL.js
│ ├── no_NO.js
│ ├── pl_PL.js
│ ├── pt_BR.js
│ ├── pt_PT.js
│ ├── ro_RO.js
│ ├── ru_RU.js
│ ├── sq_AL.js
│ ├── sr_RS.js
│ ├── sv_SE.js
│ ├── th_TH.js
│ ├── tr_TR.js
│ ├── ua_UA.js
│ ├── vi_VN.js
│ ├── zh_CN.js
│ └── zh_TW.js
├── package.json
├── screenshots
└── demo.gif
├── src
├── css
│ └── bootstrapValidator.css
└── js
│ ├── bootstrapValidator.js
│ ├── language
│ ├── ar_MA.js
│ ├── be_FR.js
│ ├── be_NL.js
│ ├── bg_BG.js
│ ├── cs_CZ.js
│ ├── da_DK.js
│ ├── de_DE.js
│ ├── en_US.js
│ ├── es_CL.js
│ ├── es_ES.js
│ ├── fa_IR.js
│ ├── fr_FR.js
│ ├── gr_EL.js
│ ├── he_IL.js
│ ├── hu_HU.js
│ ├── id_ID.js
│ ├── it_IT.js
│ ├── ja_JP.js
│ ├── nl_NL.js
│ ├── no_NO.js
│ ├── pl_PL.js
│ ├── pt_BR.js
│ ├── pt_PT.js
│ ├── ro_RO.js
│ ├── ru_RU.js
│ ├── sq_AL.js
│ ├── sr_RS.js
│ ├── sv_SE.js
│ ├── th_TH.js
│ ├── tr_TR.js
│ ├── ua_UA.js
│ ├── vi_VN.js
│ ├── zh_CN.js
│ └── zh_TW.js
│ └── validator
│ ├── base64.js
│ ├── between.js
│ ├── blank.js
│ ├── callback.js
│ ├── choice.js
│ ├── color.js
│ ├── creditCard.js
│ ├── cusip.js
│ ├── cvv.js
│ ├── date.js
│ ├── different.js
│ ├── digits.js
│ ├── ean.js
│ ├── emailAddress.js
│ ├── file.js
│ ├── greaterThan.js
│ ├── grid.js
│ ├── hex.js
│ ├── hexColor.js
│ ├── iban.js
│ ├── id.js
│ ├── identical.js
│ ├── imei.js
│ ├── imo.js
│ ├── integer.js
│ ├── ip.js
│ ├── isbn.js
│ ├── isin.js
│ ├── ismn.js
│ ├── issn.js
│ ├── lessThan.js
│ ├── mac.js
│ ├── meid.js
│ ├── notEmpty.js
│ ├── numeric.js
│ ├── phone.js
│ ├── regexp.js
│ ├── remote.js
│ ├── rtn.js
│ ├── sedol.js
│ ├── siren.js
│ ├── siret.js
│ ├── step.js
│ ├── stringCase.js
│ ├── stringLength.js
│ ├── uri.js
│ ├── uuid.js
│ ├── vat.js
│ ├── vin.js
│ └── zipCode.js
├── test
├── index.html
├── spec.js
└── spec
│ ├── api.js
│ ├── autoFocus.js
│ ├── container.js
│ ├── dynamic.js
│ ├── enable.js
│ ├── event.js
│ ├── excluded.js
│ ├── group.js
│ ├── i18n.js
│ ├── message.js
│ ├── submit.js
│ ├── validator
│ ├── between.js
│ ├── callback.js
│ ├── color.js
│ ├── creditCard.js
│ ├── date.js
│ ├── ean.js
│ ├── emailAddress.js
│ ├── greaterThan.js
│ ├── iban.js
│ ├── id.js
│ ├── imo.js
│ ├── ip.js
│ ├── isbn.js
│ ├── isin.js
│ ├── ismn.js
│ ├── issn.js
│ ├── lessThan.js
│ ├── meid.js
│ ├── phone.js
│ ├── stringLength.js
│ ├── uri.js
│ ├── vat.js
│ └── zipCode.js
│ └── verbose.js
└── vendor
├── bootstrap
├── css
│ ├── bootstrap-theme.css
│ ├── bootstrap-theme.css.map
│ ├── bootstrap-theme.min.css
│ ├── bootstrap.css
│ ├── bootstrap.css.map
│ └── bootstrap.min.css
├── fonts
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ └── glyphicons-halflings-regular.woff
└── js
│ ├── bootstrap.js
│ ├── bootstrap.min.js
│ └── npm.js
├── jasmine
├── boot.js
├── console.js
├── jasmine-html.js
├── jasmine.css
├── jasmine.js
└── jasmine_favicon.png
└── jquery
└── jquery.min.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | _gh_pages
3 | node_modules
4 | bower_components
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | grunt.initConfig({
3 | // ---
4 | // Variables
5 | // ---
6 |
7 | pkg: grunt.file.readJSON('package.json'),
8 |
9 | dirs: {
10 | src: 'src',
11 | dist: 'dist',
12 | test: 'test'
13 | },
14 |
15 | banner: [
16 | '/*!',
17 | ' * BootstrapValidator (<%= pkg.homepage %>)',
18 | ' * <%= pkg.description %>',
19 | ' *',
20 | ' * @version v<%= pkg.version %>, built on <%= grunt.template.today("yyyy-mm-dd h:MM:ss TT") %>',
21 | ' * @author <%= pkg.author.url %>',
22 | ' * @copyright (c) 2013 - <%= grunt.template.today("yyyy") %> Nguyen Huu Phuoc',
23 | ' * @license Commercial: <%= pkg.homepage %>/license/',
24 | ' * Non-commercial: http://creativecommons.org/licenses/by-nc-nd/3.0/',
25 | ' */\n'
26 | ].join('\n'),
27 |
28 | // ---
29 | // Tasks
30 | // ---
31 |
32 | copy: {
33 | main: {
34 | files: [
35 | { cwd: '<%= dirs.src %>/css', src: '**', dest: '<%= dirs.dist %>/css', expand: true, flatten: true, filter: 'isFile' },
36 | { cwd: '<%= dirs.src %>/js/language', src: '**', dest: '<%= dirs.dist %>/js/language', expand: true, flatten: true, filter: 'isFile' }
37 | ]
38 | }
39 | },
40 |
41 | cssmin: {
42 | minify: { expand: true, cwd: '<%= dirs.src %>/css/', src: ['*.css'], dest: '<%= dirs.dist %>/css/', ext: '.min.css' },
43 | add_banner: {
44 | options: {
45 | stripBanners: true,
46 | banner: '<%= banner %>'
47 | },
48 | files: {
49 | '<%= dirs.dist %>/css/bootstrapValidator.min.css': ['<%= dirs.src %>/css/bootstrapValidator.css']
50 | }
51 | }
52 | },
53 |
54 | concat: {
55 | source: {
56 | options: {
57 | separator: ';',
58 | stripBanners: true,
59 | banner: '<%= banner %>'
60 | },
61 | src: ['<%= dirs.src %>/js/bootstrapValidator.js', '<%= dirs.src %>/js/validator/*.js'],
62 | dest: '<%= dirs.dist %>/js/bootstrapValidator.js'
63 | },
64 | test: {
65 | src: ['<%= dirs.test %>/spec/*.js', '<%= dirs.test %>/spec/validator/*.js'],
66 | dest: '<%= dirs.test %>/spec.js'
67 | }
68 | },
69 |
70 | uglify: {
71 | options: {
72 | banner: '<%= banner %>'
73 | },
74 | build: {
75 | src: ['<%= dirs.dist %>/js/bootstrapValidator.js'],
76 | dest: '<%= dirs.dist %>/js/bootstrapValidator.min.js'
77 | }
78 | },
79 |
80 | jshint: {
81 | all: [
82 | '<%= dirs.src %>/js/**/*.js'
83 | ],
84 | options: {
85 | browser: true,
86 | camelcase: true,
87 | curly: true,
88 | eqeqeq: true,
89 | eqnull: true,
90 | es3: true,
91 | expr: true,
92 | laxbreak: true, // Allow line breaking before && or ||
93 | loopfunc: true,
94 | newcap: true,
95 | noarg: true,
96 | onevar: true,
97 | sub: true,
98 | undef: true,
99 | white: true
100 | }
101 | },
102 |
103 | watch: {
104 | source: {
105 | files: ['<%= dirs.src %>/css/**', '<%= dirs.src %>/js/**'],
106 | tasks: ['build'],
107 | options: {
108 | spawn: false
109 | }
110 | },
111 | test: {
112 | files: ['<%= dirs.test %>/spec/**'],
113 | tasks: ['concat:test']
114 | }
115 | }
116 | });
117 |
118 | grunt.registerTask('default', 'build');
119 | grunt.registerTask('build', ['copy', 'cssmin', 'concat', 'uglify']);
120 |
121 | grunt.loadNpmTasks('grunt-contrib-concat');
122 | grunt.loadNpmTasks('grunt-contrib-copy');
123 | grunt.loadNpmTasks('grunt-contrib-cssmin');
124 | grunt.loadNpmTasks('grunt-contrib-jshint');
125 | grunt.loadNpmTasks('grunt-contrib-uglify');
126 | grunt.loadNpmTasks('grunt-contrib-watch');
127 | };
128 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | BootstrapValidator Licenses
2 | ---
3 |
4 | BootstrapValidator is free to use in non-commercial projects under the terms of the Creative
5 | Commons BY-NC-ND 3.0 (http://creativecommons.org/licenses/by-nc-nd/3.0/) license.
6 | If you use BootstrapValidator in commercial projects and products, you must purchase a commercial license.
7 |
8 | For more information about the license, see http://bootstrapvalidator.com/license/
9 |
10 | ## BootstrapValidator commercial license agreement
11 |
12 | This Commercial License Agreement is a binding legal agreement between you and Nguyen Huu Phuoc.
13 | By installing, copying, or using BootstrapValidator (the Software), you agree to be bound
14 | by these terms of this Agreement.
15 |
16 | ### Grant of license
17 |
18 | Subject to the payment of the fee required and the conditions herein, you are hereby granted
19 | a non-exclusive, non-transferable right to use BootstrapValidator (the Software) to design
20 | and develop commercial applications (Applications).
21 |
22 | ### Developer grant
23 |
24 | The BootstrapValidator Commercial Developer License grants one license for you as one designated
25 | user (Developer) to use the Software for developing Applications. A Developer is an individual
26 | who implements the Software into Applications, most often writing the necessary code to do so.
27 | You must purchase another separate license to the Software for each and any additional Developer,
28 | or purchase a BootstrapValidator Commercial Organization License to cover your entire organization.
29 |
30 | ### Organization grant
31 |
32 | The BootstrapValidator Commercial Organization License grants one license for your Organization
33 | as one designated, collective user (Organization) to use the Software for developing Applications.
34 | There is no limit or restriction of the number of Developers within your Organization who
35 | may develop Applications using the Software.
36 |
37 | ### Usage
38 |
39 | You are granted the right to use and to modify the source code of the Software for use in
40 | Applications. There is no limit or restriction of the number of Applications which use the
41 | Software. You own any original work authored by you. Nguyen Huu Phuoc continues to retain
42 | all copyright and other intellectual property rights in the Software. You are not permitted
43 | to move, remove, edit, or obscure any copyright, trademark, attribution, warning or disclaimer
44 | notices in the Software.
45 |
46 | You may use the Software only to create Applications that are significantly different than
47 | and do not compete with the Software. You are granted the license to distribute the Software
48 | as part of your Applications on a royalty-free basis. Users of your Applications are permitted
49 | to use the Software or your modifications of the Software as part of your Applications.
50 | Users do not need to purchase their own commercial license for the Software, so long as they
51 | are not acting as Developers, developing their own commercial Applications with the Software.
52 |
53 | ### Warranties and remedies
54 |
55 | The Software is provided "as is", without warranty of any kind, express or implied, including
56 | but not limited to the warranties of merchantability, fitness for a particular purpose and
57 | non-infringement. Nguyen Huu Phuoc's entire liability and your exclusive remedy under this
58 | agreement shall be return of the price paid for the Software.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This repository is for anyone who still use the BootstrapValidator.
2 |
3 | __It's no longer supported.__
4 |
5 | __Please upgrade to use [FormValidation](http://formvalidation.io).__
6 |
--------------------------------------------------------------------------------
/bootstrapValidator.jquery.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrapValidator",
3 | "version": "0.5.3",
4 | "title": "BootstrapValidator",
5 | "author": {
6 | "name": "Nguyen Huu Phuoc",
7 | "email": "phuoc@huuphuoc.me",
8 | "url": "https://twitter.com/nghuuphuoc"
9 | },
10 | "licenses": [
11 | {
12 | "url": "http://bootstrapvalidator.com/license/"
13 | }
14 | ],
15 | "dependencies": {
16 | "jquery": ">= 1.9.1",
17 | "bootstrap": ">= 3.0.0"
18 | },
19 | "description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
20 | "keywords": ["jQuery", "plugin", "validate", "validator", "form", "Bootstrap"],
21 | "homepage": "http://bootstrapvalidator.com",
22 | "bugs": "https://github.com/nghuuphuoc/bootstrapvalidator/issues",
23 | "maintainers": [
24 | { "name": "Nguyen Huu Phuoc", "email": "phuoc@huuphuoc.me", "url": "https://twitter.com/nghuuphuoc" }
25 | ]
26 | }
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrapvalidator",
3 | "description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
4 | "version": "0.5.3",
5 | "ignore": [
6 | "demo",
7 | "screenshots",
8 | "test",
9 | "vendor",
10 | "*.md",
11 | "bootstrapValidator.jquery.json",
12 | "Gruntfile.js",
13 | "package.json"
14 | ],
15 | "main": [
16 | "dist/css/bootstrapValidator.css",
17 | "dist/js/bootstrapValidator.js"
18 | ],
19 | "license": "http://bootstrapvalidator.com/license/",
20 | "keywords": ["jQuery", "plugin", "validate", "validator", "form", "Bootstrap"],
21 | "authors": [
22 | { "name": "Nguyen Huu Phuoc", "email": "phuoc@huuphuoc.me"," homepage": "https://twitter.com/nghuuphuoc" }
23 | ],
24 | "homepage": "http://bootstrapvalidator.com",
25 | "repository": {
26 | "type": "git",
27 | "url": "https://github.com/nghuuphuoc/bootstrapvalidator.git"
28 | },
29 | "dependencies": {
30 | "jquery": ">= 1.9.1",
31 | "bootstrap": ">= 3.0.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/demo/ajaxSubmit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Using Ajax to submit data
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
52 |
53 |
121 |
122 |
--------------------------------------------------------------------------------
/demo/ajaxSubmit.php:
--------------------------------------------------------------------------------
1 | sprintf('Welcome %s', $userName),
6 | ));
7 |
--------------------------------------------------------------------------------
/demo/container.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
54 |
55 |
98 |
99 |
--------------------------------------------------------------------------------
/demo/enable2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
54 |
55 |
111 |
112 |
--------------------------------------------------------------------------------
/demo/event2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
44 |
45 |
87 |
88 |
--------------------------------------------------------------------------------
/demo/event3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
46 |
47 |
99 |
100 |
--------------------------------------------------------------------------------
/demo/file.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
63 |
64 |
121 |
122 |
--------------------------------------------------------------------------------
/demo/remote.php:
--------------------------------------------------------------------------------
1 | 'admin@domain.com',
15 | 'administrator' => 'administrator@domain.com',
16 | 'root' => 'root@domain.com',
17 | );
18 |
19 | if (isset($_POST['username']) && array_key_exists($_POST['username'], $users)) {
20 | $valid = false;
21 | } else if (isset($_POST['email'])) {
22 | $email = $_POST['email'][0];
23 | foreach ($users as $k => $v) {
24 | if ($email == $v) {
25 | $valid = false;
26 | break;
27 | }
28 | }
29 | }
30 |
31 | echo json_encode(array(
32 | 'valid' => $valid,
33 | ));
34 |
--------------------------------------------------------------------------------
/demo/remote2.php:
--------------------------------------------------------------------------------
1 | 'admin@domain.com',
14 | 'administrator' => 'administrator@domain.com',
15 | 'root' => 'root@domain.com',
16 | );
17 |
18 | if (isset($_POST['username']) && array_key_exists($_POST['username'], $users)) {
19 | $valid = false;
20 | $message = 'The username is not available';
21 | } else if (isset($_POST['email'])) {
22 | $email = $_POST['email'];
23 | foreach ($users as $k => $v) {
24 | if ($email == $v) {
25 | $valid = false;
26 | $message = 'The email is not available';
27 | break;
28 | }
29 | }
30 | }
31 |
32 | echo json_encode(
33 | $valid ? array('valid' => $valid) : array('valid' => $valid, 'message' => $message)
34 | );
35 |
--------------------------------------------------------------------------------
/demo/selector2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BootstrapValidator demo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
50 |
51 |
91 |
92 |
--------------------------------------------------------------------------------
/demo/submitHandler.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Submit Handler Demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
58 |
59 |
121 |
122 |
--------------------------------------------------------------------------------
/demo/target.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
Form data
11 |
12 |
This is a simple page showing the data you have just submitted
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/demo/tooltip.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BootstrapValidator demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
47 |
48 |
95 |
96 |
--------------------------------------------------------------------------------
/dist/css/bootstrapValidator.css:
--------------------------------------------------------------------------------
1 | /**
2 | * BootstrapValidator (http://bootstrapvalidator.com)
3 | * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
4 | *
5 | * @author http://twitter.com/nghuuphuoc
6 | * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
7 | * @license Commercial: http://bootstrapvalidator.com/license/
8 | * Non-commercial: http://creativecommons.org/licenses/by-nc-nd/3.0/
9 | */
10 |
11 | .bv-form .help-block {
12 | margin-bottom: 0;
13 | }
14 | .bv-form .tooltip-inner {
15 | text-align: left;
16 | }
17 | .nav-tabs li.bv-tab-success > a {
18 | color: #3c763d;
19 | }
20 | .nav-tabs li.bv-tab-error > a {
21 | color: #a94442;
22 | }
23 |
24 | .bv-form .bv-icon-no-label {
25 | top: 0;
26 | }
27 |
28 | .bv-form .bv-icon-input-group {
29 | top: 0;
30 | z-index: 100;
31 | }
--------------------------------------------------------------------------------
/dist/css/bootstrapValidator.min.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * BootstrapValidator (http://bootstrapvalidator.com)
3 | * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
4 | *
5 | * @version v0.5.3, built on 2014-11-05 9:14:18 PM
6 | * @author https://twitter.com/nghuuphuoc
7 | * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
8 | * @license Commercial: http://bootstrapvalidator.com/license/
9 | * Non-commercial: http://creativecommons.org/licenses/by-nc-nd/3.0/
10 | */
11 |
12 | .bv-form .help-block{margin-bottom:0}.bv-form .tooltip-inner{text-align:left}.nav-tabs li.bv-tab-success>a{color:#3c763d}.nav-tabs li.bv-tab-error>a{color:#a94442}.bv-form .bv-icon-no-label{top:0}.bv-form .bv-icon-input-group{top:0;z-index:100}
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrapValidator",
3 | "version": "0.5.3",
4 | "description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
5 | "keywords": ["jQuery", "plugin", "validate", "validator", "form", "Bootstrap"],
6 | "author": {
7 | "name": "Nguyen Huu Phuoc",
8 | "email": "phuoc@huuphuoc.me",
9 | "url": "https://twitter.com/nghuuphuoc"
10 | },
11 | "homepage": "http://bootstrapvalidator.com",
12 | "bugs": {
13 | "url": "https://github.com/nghuuphuoc/bootstrapvalidator/issues",
14 | "email": "phuoc@huuphuoc.me"
15 | },
16 | "license": "http://bootstrapvalidator.com/license/",
17 | "main": "./dist/js/bootstrapValidator.js",
18 | "repository": {
19 | "type": "git",
20 | "url": "https://github.com/nghuuphuoc/bootstrapvalidator.git"
21 | },
22 | "devDependencies": {
23 | "grunt": "latest",
24 | "grunt-contrib-concat": "latest",
25 | "grunt-contrib-copy": "latest",
26 | "grunt-contrib-cssmin": "latest",
27 | "grunt-contrib-jshint": "latest",
28 | "grunt-contrib-uglify": "latest",
29 | "grunt-contrib-watch": "latest"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/screenshots/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nghuuphuoc/bootstrapvalidator/0c96659eda586269c02a45948744ac135676ff0d/screenshots/demo.gif
--------------------------------------------------------------------------------
/src/css/bootstrapValidator.css:
--------------------------------------------------------------------------------
1 | /**
2 | * BootstrapValidator (http://bootstrapvalidator.com)
3 | * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
4 | *
5 | * @author http://twitter.com/nghuuphuoc
6 | * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
7 | * @license Commercial: http://bootstrapvalidator.com/license/
8 | * Non-commercial: http://creativecommons.org/licenses/by-nc-nd/3.0/
9 | */
10 |
11 | .bv-form .help-block {
12 | margin-bottom: 0;
13 | }
14 | .bv-form .tooltip-inner {
15 | text-align: left;
16 | }
17 | .nav-tabs li.bv-tab-success > a {
18 | color: #3c763d;
19 | }
20 | .nav-tabs li.bv-tab-error > a {
21 | color: #a94442;
22 | }
23 |
24 | .bv-form .bv-icon-no-label {
25 | top: 0;
26 | }
27 |
28 | .bv-form .bv-icon-input-group {
29 | top: 0;
30 | z-index: 100;
31 | }
--------------------------------------------------------------------------------
/src/js/validator/base64.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.base64 = $.extend($.fn.bootstrapValidator.i18n.base64 || {}, {
3 | 'default': 'Please enter a valid base 64 encoded'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.base64 = {
7 | /**
8 | * Return true if the input value is a base 64 encoded string.
9 | *
10 | * @param {BootstrapValidator} validator The validator plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} options Can consist of the following keys:
13 | * - message: The invalid message
14 | * @returns {Boolean}
15 | */
16 | validate: function(validator, $field, options) {
17 | var value = $field.val();
18 | if (value === '') {
19 | return true;
20 | }
21 |
22 | return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/.test(value);
23 | }
24 | };
25 | }(window.jQuery));
26 |
--------------------------------------------------------------------------------
/src/js/validator/between.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.between = $.extend($.fn.bootstrapValidator.i18n.between || {}, {
3 | 'default': 'Please enter a value between %s and %s',
4 | notInclusive: 'Please enter a value between %s and %s strictly'
5 | });
6 |
7 | $.fn.bootstrapValidator.validators.between = {
8 | html5Attributes: {
9 | message: 'message',
10 | min: 'min',
11 | max: 'max',
12 | inclusive: 'inclusive'
13 | },
14 |
15 | enableByHtml5: function($field) {
16 | if ('range' === $field.attr('type')) {
17 | return {
18 | min: $field.attr('min'),
19 | max: $field.attr('max')
20 | };
21 | }
22 |
23 | return false;
24 | },
25 |
26 | /**
27 | * Return true if the input value is between (strictly or not) two given numbers
28 | *
29 | * @param {BootstrapValidator} validator The validator plugin instance
30 | * @param {jQuery} $field Field element
31 | * @param {Object} options Can consist of the following keys:
32 | * - min
33 | * - max
34 | *
35 | * The min, max keys define the number which the field value compares to. min, max can be
36 | * - A number
37 | * - Name of field which its value defines the number
38 | * - Name of callback function that returns the number
39 | * - A callback function that returns the number
40 | *
41 | * - inclusive [optional]: Can be true or false. Default is true
42 | * - message: The invalid message
43 | * @returns {Boolean|Object}
44 | */
45 | validate: function(validator, $field, options) {
46 | var value = $field.val();
47 | if (value === '') {
48 | return true;
49 | }
50 |
51 | value = this._format(value);
52 | if (!$.isNumeric(value)) {
53 | return false;
54 | }
55 |
56 | var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
57 | max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
58 | minValue = this._format(min),
59 | maxValue = this._format(max);
60 |
61 | value = parseFloat(value);
62 | return (options.inclusive === true || options.inclusive === undefined)
63 | ? {
64 | valid: value >= minValue && value <= maxValue,
65 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.between['default'], [min, max])
66 | }
67 | : {
68 | valid: value > minValue && value < maxValue,
69 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.between.notInclusive, [min, max])
70 | };
71 | },
72 |
73 | _format: function(value) {
74 | return (value + '').replace(',', '.');
75 | }
76 | };
77 | }(window.jQuery));
78 |
--------------------------------------------------------------------------------
/src/js/validator/blank.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.validators.blank = {
3 | /**
4 | * Placeholder validator that can be used to display a custom validation message
5 | * returned from the server
6 | * Example:
7 | *
8 | * (1) a "blank" validator is applied to an input field.
9 | * (2) data is entered via the UI that is unable to be validated client-side.
10 | * (3) server returns a 400 with JSON data that contains the field that failed
11 | * validation and an associated message.
12 | * (4) ajax 400 call handler does the following:
13 | *
14 | * bv.updateMessage(field, 'blank', errorMessage);
15 | * bv.updateStatus(field, 'INVALID');
16 | *
17 | * @see https://github.com/nghuuphuoc/bootstrapvalidator/issues/542
18 | * @see https://github.com/nghuuphuoc/bootstrapvalidator/pull/666
19 | * @param {BootstrapValidator} validator The validator plugin instance
20 | * @param {jQuery} $field Field element
21 | * @param {Object} options Can consist of the following keys:
22 | * - message: The invalid message
23 | * @returns {Boolean}
24 | */
25 | validate: function(validator, $field, options) {
26 | return true;
27 | }
28 | };
29 | }(window.jQuery));
30 |
--------------------------------------------------------------------------------
/src/js/validator/callback.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.callback = $.extend($.fn.bootstrapValidator.i18n.callback || {}, {
3 | 'default': 'Please enter a valid value'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.callback = {
7 | html5Attributes: {
8 | message: 'message',
9 | callback: 'callback'
10 | },
11 |
12 | /**
13 | * Return result from the callback method
14 | *
15 | * @param {BootstrapValidator} validator The validator plugin instance
16 | * @param {jQuery} $field Field element
17 | * @param {Object} options Can consist of the following keys:
18 | * - callback: The callback method that passes 2 parameters:
19 | * callback: function(fieldValue, validator, $field) {
20 | * // fieldValue is the value of field
21 | * // validator is instance of BootstrapValidator
22 | * // $field is the field element
23 | * }
24 | * - message: The invalid message
25 | * @returns {Deferred}
26 | */
27 | validate: function(validator, $field, options) {
28 | var value = $field.val(),
29 | dfd = new $.Deferred(),
30 | result = { valid: true };
31 |
32 | if (options.callback) {
33 | var response = $.fn.bootstrapValidator.helpers.call(options.callback, [value, validator, $field]);
34 | result = ('boolean' === typeof response) ? { valid: response } : response;
35 | }
36 |
37 | dfd.resolve($field, 'callback', result);
38 | return dfd;
39 | }
40 | };
41 | }(window.jQuery));
42 |
--------------------------------------------------------------------------------
/src/js/validator/choice.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.choice = $.extend($.fn.bootstrapValidator.i18n.choice || {}, {
3 | 'default': 'Please enter a valid value',
4 | less: 'Please choose %s options at minimum',
5 | more: 'Please choose %s options at maximum',
6 | between: 'Please choose %s - %s options'
7 | });
8 |
9 | $.fn.bootstrapValidator.validators.choice = {
10 | html5Attributes: {
11 | message: 'message',
12 | min: 'min',
13 | max: 'max'
14 | },
15 |
16 | /**
17 | * Check if the number of checked boxes are less or more than a given number
18 | *
19 | * @param {BootstrapValidator} validator The validator plugin instance
20 | * @param {jQuery} $field Field element
21 | * @param {Object} options Consists of following keys:
22 | * - min
23 | * - max
24 | *
25 | * At least one of two keys is required
26 | * The min, max keys define the number which the field value compares to. min, max can be
27 | * - A number
28 | * - Name of field which its value defines the number
29 | * - Name of callback function that returns the number
30 | * - A callback function that returns the number
31 | *
32 | * - message: The invalid message
33 | * @returns {Object}
34 | */
35 | validate: function(validator, $field, options) {
36 | var numChoices = $field.is('select')
37 | ? validator.getFieldElements($field.attr('data-bv-field')).find('option').filter(':selected').length
38 | : validator.getFieldElements($field.attr('data-bv-field')).filter(':checked').length,
39 | min = options.min ? ($.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min)) : null,
40 | max = options.max ? ($.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max)) : null,
41 | isValid = true,
42 | message = options.message || $.fn.bootstrapValidator.i18n.choice['default'];
43 |
44 | if ((min && numChoices < parseInt(min, 10)) || (max && numChoices > parseInt(max, 10))) {
45 | isValid = false;
46 | }
47 |
48 | switch (true) {
49 | case (!!min && !!max):
50 | message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.choice.between, [parseInt(min, 10), parseInt(max, 10)]);
51 | break;
52 |
53 | case (!!min):
54 | message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.choice.less, parseInt(min, 10));
55 | break;
56 |
57 | case (!!max):
58 | message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.choice.more, parseInt(max, 10));
59 | break;
60 |
61 | default:
62 | break;
63 | }
64 |
65 | return { valid: isValid, message: message };
66 | }
67 | };
68 | }(window.jQuery));
69 |
--------------------------------------------------------------------------------
/src/js/validator/creditCard.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.creditCard = $.extend($.fn.bootstrapValidator.i18n.creditCard || {}, {
3 | 'default': 'Please enter a valid credit card number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.creditCard = {
7 | /**
8 | * Return true if the input value is valid credit card number
9 | * Based on https://gist.github.com/DiegoSalazar/4075533
10 | *
11 | * @param {BootstrapValidator} validator The validator plugin instance
12 | * @param {jQuery} $field Field element
13 | * @param {Object} [options] Can consist of the following key:
14 | * - message: The invalid message
15 | * @returns {Boolean}
16 | */
17 | validate: function(validator, $field, options) {
18 | var value = $field.val();
19 | if (value === '') {
20 | return true;
21 | }
22 |
23 | // Accept only digits, dashes or spaces
24 | if (/[^0-9-\s]+/.test(value)) {
25 | return false;
26 | }
27 | value = value.replace(/\D/g, '');
28 |
29 | if (!$.fn.bootstrapValidator.helpers.luhn(value)) {
30 | return false;
31 | }
32 |
33 | // Validate the card number based on prefix (IIN ranges) and length
34 | var cards = {
35 | AMERICAN_EXPRESS: {
36 | length: [15],
37 | prefix: ['34', '37']
38 | },
39 | DINERS_CLUB: {
40 | length: [14],
41 | prefix: ['300', '301', '302', '303', '304', '305', '36']
42 | },
43 | DINERS_CLUB_US: {
44 | length: [16],
45 | prefix: ['54', '55']
46 | },
47 | DISCOVER: {
48 | length: [16],
49 | prefix: ['6011', '622126', '622127', '622128', '622129', '62213',
50 | '62214', '62215', '62216', '62217', '62218', '62219',
51 | '6222', '6223', '6224', '6225', '6226', '6227', '6228',
52 | '62290', '62291', '622920', '622921', '622922', '622923',
53 | '622924', '622925', '644', '645', '646', '647', '648',
54 | '649', '65']
55 | },
56 | JCB: {
57 | length: [16],
58 | prefix: ['3528', '3529', '353', '354', '355', '356', '357', '358']
59 | },
60 | LASER: {
61 | length: [16, 17, 18, 19],
62 | prefix: ['6304', '6706', '6771', '6709']
63 | },
64 | MAESTRO: {
65 | length: [12, 13, 14, 15, 16, 17, 18, 19],
66 | prefix: ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766']
67 | },
68 | MASTERCARD: {
69 | length: [16],
70 | prefix: ['51', '52', '53', '54', '55']
71 | },
72 | SOLO: {
73 | length: [16, 18, 19],
74 | prefix: ['6334', '6767']
75 | },
76 | UNIONPAY: {
77 | length: [16, 17, 18, 19],
78 | prefix: ['622126', '622127', '622128', '622129', '62213', '62214',
79 | '62215', '62216', '62217', '62218', '62219', '6222', '6223',
80 | '6224', '6225', '6226', '6227', '6228', '62290', '62291',
81 | '622920', '622921', '622922', '622923', '622924', '622925']
82 | },
83 | VISA: {
84 | length: [16],
85 | prefix: ['4']
86 | }
87 | };
88 |
89 | var type, i;
90 | for (type in cards) {
91 | for (i in cards[type].prefix) {
92 | if (value.substr(0, cards[type].prefix[i].length) === cards[type].prefix[i] // Check the prefix
93 | && $.inArray(value.length, cards[type].length) !== -1) // and length
94 | {
95 | return true;
96 | }
97 | }
98 | }
99 |
100 | return false;
101 | }
102 | };
103 | }(window.jQuery));
104 |
--------------------------------------------------------------------------------
/src/js/validator/cusip.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.cusip = $.extend($.fn.bootstrapValidator.i18n.cusip || {}, {
3 | 'default': 'Please enter a valid CUSIP number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.cusip = {
7 | /**
8 | * Validate a CUSIP
9 | * Examples:
10 | * - Valid: 037833100, 931142103, 14149YAR8, 126650BG6
11 | * - Invalid: 31430F200, 022615AC2
12 | *
13 | * @see http://en.wikipedia.org/wiki/CUSIP
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} [options] Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | value = value.toUpperCase();
27 | if (!/^[0-9A-Z]{9}$/.test(value)) {
28 | return false;
29 | }
30 |
31 | var converted = $.map(value.split(''), function(item) {
32 | var code = item.charCodeAt(0);
33 | return (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0))
34 | // Replace A, B, C, ..., Z with 10, 11, ..., 35
35 | ? (code - 'A'.charCodeAt(0) + 10)
36 | : item;
37 | }),
38 | length = converted.length,
39 | sum = 0;
40 | for (var i = 0; i < length - 1; i++) {
41 | var num = parseInt(converted[i], 10);
42 | if (i % 2 !== 0) {
43 | num *= 2;
44 | }
45 | if (num > 9) {
46 | num -= 9;
47 | }
48 | sum += num;
49 | }
50 |
51 | sum = (10 - (sum % 10)) % 10;
52 | return sum === converted[length - 1];
53 | }
54 | };
55 | }(window.jQuery));
56 |
--------------------------------------------------------------------------------
/src/js/validator/cvv.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.cvv = $.extend($.fn.bootstrapValidator.i18n.cvv || {}, {
3 | 'default': 'Please enter a valid CVV number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.cvv = {
7 | html5Attributes: {
8 | message: 'message',
9 | ccfield: 'creditCardField'
10 | },
11 |
12 | /**
13 | * Return true if the input value is a valid CVV number.
14 | *
15 | * @param {BootstrapValidator} validator The validator plugin instance
16 | * @param {jQuery} $field Field element
17 | * @param {Object} options Can consist of the following keys:
18 | * - creditCardField: The credit card number field. It can be null
19 | * - message: The invalid message
20 | * @returns {Boolean}
21 | */
22 | validate: function(validator, $field, options) {
23 | var value = $field.val();
24 | if (value === '') {
25 | return true;
26 | }
27 |
28 | if (!/^[0-9]{3,4}$/.test(value)) {
29 | return false;
30 | }
31 |
32 | if (!options.creditCardField) {
33 | return true;
34 | }
35 |
36 | // Get the credit card number
37 | var creditCard = validator.getFieldElements(options.creditCardField).val();
38 | if (creditCard === '') {
39 | return true;
40 | }
41 |
42 | creditCard = creditCard.replace(/\D/g, '');
43 |
44 | // Supported credit card types
45 | var cards = {
46 | AMERICAN_EXPRESS: {
47 | length: [15],
48 | prefix: ['34', '37']
49 | },
50 | DINERS_CLUB: {
51 | length: [14],
52 | prefix: ['300', '301', '302', '303', '304', '305', '36']
53 | },
54 | DINERS_CLUB_US: {
55 | length: [16],
56 | prefix: ['54', '55']
57 | },
58 | DISCOVER: {
59 | length: [16],
60 | prefix: ['6011', '622126', '622127', '622128', '622129', '62213',
61 | '62214', '62215', '62216', '62217', '62218', '62219',
62 | '6222', '6223', '6224', '6225', '6226', '6227', '6228',
63 | '62290', '62291', '622920', '622921', '622922', '622923',
64 | '622924', '622925', '644', '645', '646', '647', '648',
65 | '649', '65']
66 | },
67 | JCB: {
68 | length: [16],
69 | prefix: ['3528', '3529', '353', '354', '355', '356', '357', '358']
70 | },
71 | LASER: {
72 | length: [16, 17, 18, 19],
73 | prefix: ['6304', '6706', '6771', '6709']
74 | },
75 | MAESTRO: {
76 | length: [12, 13, 14, 15, 16, 17, 18, 19],
77 | prefix: ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766']
78 | },
79 | MASTERCARD: {
80 | length: [16],
81 | prefix: ['51', '52', '53', '54', '55']
82 | },
83 | SOLO: {
84 | length: [16, 18, 19],
85 | prefix: ['6334', '6767']
86 | },
87 | UNIONPAY: {
88 | length: [16, 17, 18, 19],
89 | prefix: ['622126', '622127', '622128', '622129', '62213', '62214',
90 | '62215', '62216', '62217', '62218', '62219', '6222', '6223',
91 | '6224', '6225', '6226', '6227', '6228', '62290', '62291',
92 | '622920', '622921', '622922', '622923', '622924', '622925']
93 | },
94 | VISA: {
95 | length: [16],
96 | prefix: ['4']
97 | }
98 | };
99 | var type, i, creditCardType = null;
100 | for (type in cards) {
101 | for (i in cards[type].prefix) {
102 | if (creditCard.substr(0, cards[type].prefix[i].length) === cards[type].prefix[i] // Check the prefix
103 | && $.inArray(creditCard.length, cards[type].length) !== -1) // and length
104 | {
105 | creditCardType = type;
106 | break;
107 | }
108 | }
109 | }
110 |
111 | return (creditCardType === null)
112 | ? false
113 | : (('AMERICAN_EXPRESS' === creditCardType) ? (value.length === 4) : (value.length === 3));
114 | }
115 | };
116 | }(window.jQuery));
117 |
--------------------------------------------------------------------------------
/src/js/validator/different.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.different = $.extend($.fn.bootstrapValidator.i18n.different || {}, {
3 | 'default': 'Please enter a different value'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.different = {
7 | html5Attributes: {
8 | message: 'message',
9 | field: 'field'
10 | },
11 |
12 | /**
13 | * Return true if the input value is different with given field's value
14 | *
15 | * @param {BootstrapValidator} validator The validator plugin instance
16 | * @param {jQuery} $field Field element
17 | * @param {Object} options Consists of the following key:
18 | * - field: The name of field that will be used to compare with current one
19 | * - message: The invalid message
20 | * @returns {Boolean}
21 | */
22 | validate: function(validator, $field, options) {
23 | var value = $field.val();
24 | if (value === '') {
25 | return true;
26 | }
27 |
28 | var fields = options.field.split(','),
29 | isValid = true;
30 |
31 | for (var i = 0; i < fields.length; i++) {
32 | var compareWith = validator.getFieldElements(fields[i]);
33 | if (compareWith == null || compareWith.length === 0) {
34 | continue;
35 | }
36 |
37 | var compareValue = compareWith.val();
38 | if (value === compareValue) {
39 | isValid = false;
40 | } else if (compareValue !== '') {
41 | validator.updateStatus(compareWith, validator.STATUS_VALID, 'different');
42 | }
43 | }
44 |
45 | return isValid;
46 | }
47 | };
48 | }(window.jQuery));
49 |
--------------------------------------------------------------------------------
/src/js/validator/digits.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.digits = $.extend($.fn.bootstrapValidator.i18n.digits || {}, {
3 | 'default': 'Please enter only digits'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.digits = {
7 | /**
8 | * Return true if the input value contains digits only
9 | *
10 | * @param {BootstrapValidator} validator Validate plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} [options]
13 | * @returns {Boolean}
14 | */
15 | validate: function(validator, $field, options) {
16 | var value = $field.val();
17 | if (value === '') {
18 | return true;
19 | }
20 |
21 | return /^\d+$/.test(value);
22 | }
23 | };
24 | }(window.jQuery));
25 |
--------------------------------------------------------------------------------
/src/js/validator/ean.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.ean = $.extend($.fn.bootstrapValidator.i18n.ean || {}, {
3 | 'default': 'Please enter a valid EAN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.ean = {
7 | /**
8 | * Validate EAN (International Article Number)
9 | * Examples:
10 | * - Valid: 73513537, 9780471117094, 4006381333931
11 | * - Invalid: 73513536
12 | *
13 | * @see http://en.wikipedia.org/wiki/European_Article_Number
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | if (!/^(\d{8}|\d{12}|\d{13})$/.test(value)) {
27 | return false;
28 | }
29 |
30 | var length = value.length,
31 | sum = 0,
32 | weight = (length === 8) ? [3, 1] : [1, 3];
33 | for (var i = 0; i < length - 1; i++) {
34 | sum += parseInt(value.charAt(i), 10) * weight[i % 2];
35 | }
36 | sum = (10 - sum % 10) % 10;
37 | return (sum + '' === value.charAt(length - 1));
38 | }
39 | };
40 | }(window.jQuery));
41 |
--------------------------------------------------------------------------------
/src/js/validator/emailAddress.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.emailAddress = $.extend($.fn.bootstrapValidator.i18n.emailAddress || {}, {
3 | 'default': 'Please enter a valid email address'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.emailAddress = {
7 | html5Attributes: {
8 | message: 'message',
9 | multiple: 'multiple',
10 | separator: 'separator'
11 | },
12 |
13 | enableByHtml5: function($field) {
14 | return ('email' === $field.attr('type'));
15 | },
16 |
17 | /**
18 | * Return true if and only if the input value is a valid email address
19 | *
20 | * @param {BootstrapValidator} validator Validate plugin instance
21 | * @param {jQuery} $field Field element
22 | * @param {Object} [options]
23 | * - multiple: Allow multiple email addresses, separated by a comma or semicolon; default is false.
24 | * - separator: Regex for character or characters expected as separator between addresses; default is comma /[,;]/, i.e. comma or semicolon.
25 | * @returns {Boolean}
26 | */
27 | validate: function(validator, $field, options) {
28 | var value = $field.val();
29 | if (value === '') {
30 | return true;
31 | }
32 |
33 | // Email address regular expression
34 | // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
35 | var emailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
36 | allowMultiple = options.multiple === true || options.multiple === 'true';
37 |
38 | if (allowMultiple) {
39 | var separator = options.separator || /[,;]/,
40 | addresses = this._splitEmailAddresses(value, separator);
41 |
42 | for (var i = 0; i < addresses.length; i++) {
43 | if (!emailRegExp.test(addresses[i])) {
44 | return false;
45 | }
46 | }
47 |
48 | return true;
49 | } else {
50 | return emailRegExp.test(value);
51 | }
52 | },
53 |
54 | _splitEmailAddresses: function(emailAddresses, separator) {
55 | var quotedFragments = emailAddresses.split(/"/),
56 | quotedFragmentCount = quotedFragments.length,
57 | emailAddressArray = [],
58 | nextEmailAddress = '';
59 |
60 | for (var i = 0; i < quotedFragmentCount; i++) {
61 | if (i % 2 === 0) {
62 | var splitEmailAddressFragments = quotedFragments[i].split(separator),
63 | splitEmailAddressFragmentCount = splitEmailAddressFragments.length;
64 |
65 | if (splitEmailAddressFragmentCount === 1) {
66 | nextEmailAddress += splitEmailAddressFragments[0];
67 | } else {
68 | emailAddressArray.push(nextEmailAddress + splitEmailAddressFragments[0]);
69 |
70 | for (var j = 1; j < splitEmailAddressFragmentCount - 1; j++) {
71 | emailAddressArray.push(splitEmailAddressFragments[j]);
72 | }
73 | nextEmailAddress = splitEmailAddressFragments[splitEmailAddressFragmentCount - 1];
74 | }
75 | } else {
76 | nextEmailAddress += '"' + quotedFragments[i];
77 | if (i < quotedFragmentCount - 1) {
78 | nextEmailAddress += '"';
79 | }
80 | }
81 | }
82 |
83 | emailAddressArray.push(nextEmailAddress);
84 | return emailAddressArray;
85 | }
86 | };
87 | }(window.jQuery));
88 |
--------------------------------------------------------------------------------
/src/js/validator/file.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.file = $.extend($.fn.bootstrapValidator.i18n.file || {}, {
3 | 'default': 'Please choose a valid file'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.file = {
7 | html5Attributes: {
8 | extension: 'extension',
9 | maxfiles: 'maxFiles',
10 | minfiles: 'minFiles',
11 | maxsize: 'maxSize',
12 | minsize: 'minSize',
13 | maxtotalsize: 'maxTotalSize',
14 | mintotalsize: 'minTotalSize',
15 | message: 'message',
16 | type: 'type'
17 | },
18 |
19 | /**
20 | * Validate upload file. Use HTML 5 API if the browser supports
21 | *
22 | * @param {BootstrapValidator} validator The validator plugin instance
23 | * @param {jQuery} $field Field element
24 | * @param {Object} options Can consist of the following keys:
25 | * - extension: The allowed extensions, separated by a comma
26 | * - maxFiles: The maximum number of files
27 | * - minFiles: The minimum number of files
28 | * - maxSize: The maximum size in bytes
29 | * - minSize: The minimum size in bytes
30 | * - maxTotalSize: The maximum size in bytes for all files
31 | * - minTotalSize: The minimum size in bytes for all files
32 | * - message: The invalid message
33 | * - type: The allowed MIME type, separated by a comma
34 | * @returns {Boolean}
35 | */
36 | validate: function(validator, $field, options) {
37 | var value = $field.val();
38 | if (value === '') {
39 | return true;
40 | }
41 |
42 | var ext,
43 | extensions = options.extension ? options.extension.toLowerCase().split(',') : null,
44 | types = options.type ? options.type.toLowerCase().split(',') : null,
45 | html5 = (window.File && window.FileList && window.FileReader);
46 |
47 | if (html5) {
48 | // Get FileList instance
49 | var files = $field.get(0).files,
50 | total = files.length,
51 | totalSize = 0;
52 |
53 | if ((options.maxFiles && total > parseInt(options.maxFiles, 10)) // Check the maxFiles
54 | || (options.minFiles && total < parseInt(options.minFiles, 10))) // Check the minFiles
55 | {
56 | return false;
57 | }
58 |
59 | for (var i = 0; i < total; i++) {
60 | totalSize += files[i].size;
61 | ext = files[i].name.substr(files[i].name.lastIndexOf('.') + 1);
62 |
63 | if ((options.minSize && files[i].size < parseInt(options.minSize, 10)) // Check the minSize
64 | || (options.maxSize && files[i].size > parseInt(options.maxSize, 10)) // Check the maxSize
65 | || (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) // Check file extension
66 | || (files[i].type && types && $.inArray(files[i].type.toLowerCase(), types) === -1)) // Check file type
67 | {
68 | return false;
69 | }
70 | }
71 |
72 | if ((options.maxTotalSize && totalSize > parseInt(options.maxTotalSize, 10)) // Check the maxTotalSize
73 | || (options.minTotalSize && totalSize < parseInt(options.minTotalSize, 10))) // Check the minTotalSize
74 | {
75 | return false;
76 | }
77 | } else {
78 | // Check file extension
79 | ext = value.substr(value.lastIndexOf('.') + 1);
80 | if (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) {
81 | return false;
82 | }
83 | }
84 |
85 | return true;
86 | }
87 | };
88 | }(window.jQuery));
89 |
--------------------------------------------------------------------------------
/src/js/validator/greaterThan.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.greaterThan = $.extend($.fn.bootstrapValidator.i18n.greaterThan || {}, {
3 | 'default': 'Please enter a value greater than or equal to %s',
4 | notInclusive: 'Please enter a value greater than %s'
5 | });
6 |
7 | $.fn.bootstrapValidator.validators.greaterThan = {
8 | html5Attributes: {
9 | message: 'message',
10 | value: 'value',
11 | inclusive: 'inclusive'
12 | },
13 |
14 | enableByHtml5: function($field) {
15 | var type = $field.attr('type'),
16 | min = $field.attr('min');
17 | if (min && type !== 'date') {
18 | return {
19 | value: min
20 | };
21 | }
22 |
23 | return false;
24 | },
25 |
26 | /**
27 | * Return true if the input value is greater than or equals to given number
28 | *
29 | * @param {BootstrapValidator} validator Validate plugin instance
30 | * @param {jQuery} $field Field element
31 | * @param {Object} options Can consist of the following keys:
32 | * - value: Define the number to compare with. It can be
33 | * - A number
34 | * - Name of field which its value defines the number
35 | * - Name of callback function that returns the number
36 | * - A callback function that returns the number
37 | *
38 | * - inclusive [optional]: Can be true or false. Default is true
39 | * - message: The invalid message
40 | * @returns {Boolean|Object}
41 | */
42 | validate: function(validator, $field, options) {
43 | var value = $field.val();
44 | if (value === '') {
45 | return true;
46 | }
47 |
48 | value = this._format(value);
49 | if (!$.isNumeric(value)) {
50 | return false;
51 | }
52 |
53 | var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
54 | compareToValue = this._format(compareTo);
55 |
56 | value = parseFloat(value);
57 | return (options.inclusive === true || options.inclusive === undefined)
58 | ? {
59 | valid: value >= compareToValue,
60 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan['default'], compareTo)
61 | }
62 | : {
63 | valid: value > compareToValue,
64 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan.notInclusive, compareTo)
65 | };
66 | },
67 |
68 | _format: function(value) {
69 | return (value + '').replace(',', '.');
70 | }
71 | };
72 | }(window.jQuery));
73 |
--------------------------------------------------------------------------------
/src/js/validator/grid.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.grid = $.extend($.fn.bootstrapValidator.i18n.grid || {}, {
3 | 'default': 'Please enter a valid GRId number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.grid = {
7 | /**
8 | * Validate GRId (Global Release Identifier)
9 | * Examples:
10 | * - Valid: A12425GABC1234002M, A1-2425G-ABC1234002-M, A1 2425G ABC1234002 M, Grid:A1-2425G-ABC1234002-M
11 | * - Invalid: A1-2425G-ABC1234002-Q
12 | *
13 | * @see http://en.wikipedia.org/wiki/Global_Release_Identifier
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | value = value.toUpperCase();
27 | if (!/^[GRID:]*([0-9A-Z]{2})[-\s]*([0-9A-Z]{5})[-\s]*([0-9A-Z]{10})[-\s]*([0-9A-Z]{1})$/g.test(value)) {
28 | return false;
29 | }
30 | value = value.replace(/\s/g, '').replace(/-/g, '');
31 | if ('GRID:' === value.substr(0, 5)) {
32 | value = value.substr(5);
33 | }
34 | return $.fn.bootstrapValidator.helpers.mod37And36(value);
35 | }
36 | };
37 | }(window.jQuery));
38 |
--------------------------------------------------------------------------------
/src/js/validator/hex.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.hex = $.extend($.fn.bootstrapValidator.i18n.hex || {}, {
3 | 'default': 'Please enter a valid hexadecimal number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.hex = {
7 | /**
8 | * Return true if and only if the input value is a valid hexadecimal number
9 | *
10 | * @param {BootstrapValidator} validator The validator plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} options Consist of key:
13 | * - message: The invalid message
14 | * @returns {Boolean}
15 | */
16 | validate: function(validator, $field, options) {
17 | var value = $field.val();
18 | if (value === '') {
19 | return true;
20 | }
21 |
22 | return /^[0-9a-fA-F]+$/.test(value);
23 | }
24 | };
25 | }(window.jQuery));
26 |
--------------------------------------------------------------------------------
/src/js/validator/hexColor.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.hexColor = $.extend($.fn.bootstrapValidator.i18n.hexColor || {}, {
3 | 'default': 'Please enter a valid hex color'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.hexColor = {
7 | enableByHtml5: function($field) {
8 | return ('color' === $field.attr('type'));
9 | },
10 |
11 | /**
12 | * Return true if the input value is a valid hex color
13 | *
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | return ('color' === $field.attr('type'))
27 | // Only accept 6 hex character values due to the HTML 5 spec
28 | // See http://www.w3.org/TR/html-markup/input.color.html#input.color.attrs.value
29 | ? /^#[0-9A-F]{6}$/i.test(value)
30 | : /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
31 | }
32 | };
33 | }(window.jQuery));
34 |
--------------------------------------------------------------------------------
/src/js/validator/identical.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.identical = $.extend($.fn.bootstrapValidator.i18n.identical || {}, {
3 | 'default': 'Please enter the same value'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.identical = {
7 | html5Attributes: {
8 | message: 'message',
9 | field: 'field'
10 | },
11 |
12 | /**
13 | * Check if input value equals to value of particular one
14 | *
15 | * @param {BootstrapValidator} validator The validator plugin instance
16 | * @param {jQuery} $field Field element
17 | * @param {Object} options Consists of the following key:
18 | * - field: The name of field that will be used to compare with current one
19 | * @returns {Boolean}
20 | */
21 | validate: function(validator, $field, options) {
22 | var value = $field.val();
23 | if (value === '') {
24 | return true;
25 | }
26 |
27 | var compareWith = validator.getFieldElements(options.field);
28 | if (compareWith === null || compareWith.length === 0) {
29 | return true;
30 | }
31 |
32 | if (value === compareWith.val()) {
33 | validator.updateStatus(options.field, validator.STATUS_VALID, 'identical');
34 | return true;
35 | } else {
36 | return false;
37 | }
38 | }
39 | };
40 | }(window.jQuery));
41 |
--------------------------------------------------------------------------------
/src/js/validator/imei.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.imei = $.extend($.fn.bootstrapValidator.i18n.imei || {}, {
3 | 'default': 'Please enter a valid IMEI number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.imei = {
7 | /**
8 | * Validate IMEI (International Mobile Station Equipment Identity)
9 | * Examples:
10 | * - Valid: 35-209900-176148-1, 35-209900-176148-23, 3568680000414120, 490154203237518
11 | * - Invalid: 490154203237517
12 | *
13 | * @see http://en.wikipedia.org/wiki/International_Mobile_Station_Equipment_Identity
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | switch (true) {
27 | case /^\d{15}$/.test(value):
28 | case /^\d{2}-\d{6}-\d{6}-\d{1}$/.test(value):
29 | case /^\d{2}\s\d{6}\s\d{6}\s\d{1}$/.test(value):
30 | value = value.replace(/[^0-9]/g, '');
31 | return $.fn.bootstrapValidator.helpers.luhn(value);
32 |
33 | case /^\d{14}$/.test(value):
34 | case /^\d{16}$/.test(value):
35 | case /^\d{2}-\d{6}-\d{6}(|-\d{2})$/.test(value):
36 | case /^\d{2}\s\d{6}\s\d{6}(|\s\d{2})$/.test(value):
37 | return true;
38 |
39 | default:
40 | return false;
41 | }
42 | }
43 | };
44 | }(window.jQuery));
45 |
--------------------------------------------------------------------------------
/src/js/validator/imo.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.imo = $.extend($.fn.bootstrapValidator.i18n.imo || {}, {
3 | 'default': 'Please enter a valid IMO number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.imo = {
7 | /**
8 | * Validate IMO (International Maritime Organization)
9 | * Examples:
10 | * - Valid: IMO 8814275, IMO 9176187
11 | * - Invalid: IMO 8814274
12 | *
13 | * @see http://en.wikipedia.org/wiki/IMO_Number
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | if (!/^IMO \d{7}$/i.test(value)) {
27 | return false;
28 | }
29 |
30 | // Grab just the digits
31 | var sum = 0,
32 | digits = value.replace(/^.*(\d{7})$/, '$1');
33 |
34 | // Go over each char, multiplying by the inverse of it's position
35 | // IMO 9176187
36 | // (9 * 7) + (1 * 6) + (7 * 5) + (6 * 4) + (1 * 3) + (8 * 2) = 147
37 | // Take the last digit of that, that's the check digit (7)
38 | for (var i = 6; i >= 1; i--) {
39 | sum += (digits.slice((6 - i), -i) * (i + 1));
40 | }
41 |
42 | return sum % 10 === parseInt(digits.charAt(6), 10);
43 | }
44 | };
45 | }(window.jQuery));
46 |
--------------------------------------------------------------------------------
/src/js/validator/integer.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.integer = $.extend($.fn.bootstrapValidator.i18n.integer || {}, {
3 | 'default': 'Please enter a valid number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.integer = {
7 | enableByHtml5: function($field) {
8 | return ('number' === $field.attr('type')) && ($field.attr('step') === undefined || $field.attr('step') % 1 === 0);
9 | },
10 |
11 | /**
12 | * Return true if the input value is an integer
13 | *
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following key:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | if (this.enableByHtml5($field) && $field.get(0).validity && $field.get(0).validity.badInput === true) {
22 | return false;
23 | }
24 |
25 | var value = $field.val();
26 | if (value === '') {
27 | return true;
28 | }
29 | return /^(?:-?(?:0|[1-9][0-9]*))$/.test(value);
30 | }
31 | };
32 | }(window.jQuery));
33 |
--------------------------------------------------------------------------------
/src/js/validator/ip.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.ip = $.extend($.fn.bootstrapValidator.i18n.ip || {}, {
3 | 'default': 'Please enter a valid IP address',
4 | ipv4: 'Please enter a valid IPv4 address',
5 | ipv6: 'Please enter a valid IPv6 address'
6 | });
7 |
8 | $.fn.bootstrapValidator.validators.ip = {
9 | html5Attributes: {
10 | message: 'message',
11 | ipv4: 'ipv4',
12 | ipv6: 'ipv6'
13 | },
14 |
15 | /**
16 | * Return true if the input value is a IP address.
17 | *
18 | * @param {BootstrapValidator} validator The validator plugin instance
19 | * @param {jQuery} $field Field element
20 | * @param {Object} options Can consist of the following keys:
21 | * - ipv4: Enable IPv4 validator, default to true
22 | * - ipv6: Enable IPv6 validator, default to true
23 | * - message: The invalid message
24 | * @returns {Boolean|Object}
25 | */
26 | validate: function(validator, $field, options) {
27 | var value = $field.val();
28 | if (value === '') {
29 | return true;
30 | }
31 | options = $.extend({}, { ipv4: true, ipv6: true }, options);
32 |
33 | var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
34 | ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,
35 | valid = false,
36 | message;
37 |
38 | switch (true) {
39 | case (options.ipv4 && !options.ipv6):
40 | valid = ipv4Regex.test(value);
41 | message = options.message || $.fn.bootstrapValidator.i18n.ip.ipv4;
42 | break;
43 |
44 | case (!options.ipv4 && options.ipv6):
45 | valid = ipv6Regex.test(value);
46 | message = options.message || $.fn.bootstrapValidator.i18n.ip.ipv6;
47 | break;
48 |
49 | case (options.ipv4 && options.ipv6):
50 | /* falls through */
51 | default:
52 | valid = ipv4Regex.test(value) || ipv6Regex.test(value);
53 | message = options.message || $.fn.bootstrapValidator.i18n.ip['default'];
54 | break;
55 | }
56 |
57 | return {
58 | valid: valid,
59 | message: message
60 | };
61 | }
62 | };
63 | }(window.jQuery));
--------------------------------------------------------------------------------
/src/js/validator/isbn.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.isbn = $.extend($.fn.bootstrapValidator.i18n.isbn || {}, {
3 | 'default': 'Please enter a valid ISBN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.isbn = {
7 | /**
8 | * Return true if the input value is a valid ISBN 10 or ISBN 13 number
9 | * Examples:
10 | * - Valid:
11 | * ISBN 10: 99921-58-10-7, 9971-5-0210-0, 960-425-059-0, 80-902734-1-6, 85-359-0277-5, 1-84356-028-3, 0-684-84328-5, 0-8044-2957-X, 0-85131-041-9, 0-943396-04-2, 0-9752298-0-X
12 | * ISBN 13: 978-0-306-40615-7
13 | * - Invalid:
14 | * ISBN 10: 99921-58-10-6
15 | * ISBN 13: 978-0-306-40615-6
16 | *
17 | * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
18 | * @param {BootstrapValidator} validator The validator plugin instance
19 | * @param {jQuery} $field Field element
20 | * @param {Object} [options] Can consist of the following keys:
21 | * - message: The invalid message
22 | * @returns {Boolean}
23 | */
24 | validate: function(validator, $field, options) {
25 | var value = $field.val();
26 | if (value === '') {
27 | return true;
28 | }
29 |
30 | // http://en.wikipedia.org/wiki/International_Standard_Book_Number#Overview
31 | // Groups are separated by a hyphen or a space
32 | var type;
33 | switch (true) {
34 | case /^\d{9}[\dX]$/.test(value):
35 | case (value.length === 13 && /^(\d+)-(\d+)-(\d+)-([\dX])$/.test(value)):
36 | case (value.length === 13 && /^(\d+)\s(\d+)\s(\d+)\s([\dX])$/.test(value)):
37 | type = 'ISBN10';
38 | break;
39 | case /^(978|979)\d{9}[\dX]$/.test(value):
40 | case (value.length === 17 && /^(978|979)-(\d+)-(\d+)-(\d+)-([\dX])$/.test(value)):
41 | case (value.length === 17 && /^(978|979)\s(\d+)\s(\d+)\s(\d+)\s([\dX])$/.test(value)):
42 | type = 'ISBN13';
43 | break;
44 | default:
45 | return false;
46 | }
47 |
48 | // Replace all special characters except digits and X
49 | value = value.replace(/[^0-9X]/gi, '');
50 | var chars = value.split(''),
51 | length = chars.length,
52 | sum = 0,
53 | i,
54 | checksum;
55 |
56 | switch (type) {
57 | case 'ISBN10':
58 | sum = 0;
59 | for (i = 0; i < length - 1; i++) {
60 | sum += parseInt(chars[i], 10) * (10 - i);
61 | }
62 | checksum = 11 - (sum % 11);
63 | if (checksum === 11) {
64 | checksum = 0;
65 | } else if (checksum === 10) {
66 | checksum = 'X';
67 | }
68 | return (checksum + '' === chars[length - 1]);
69 |
70 | case 'ISBN13':
71 | sum = 0;
72 | for (i = 0; i < length - 1; i++) {
73 | sum += ((i % 2 === 0) ? parseInt(chars[i], 10) : (parseInt(chars[i], 10) * 3));
74 | }
75 | checksum = 10 - (sum % 10);
76 | if (checksum === 10) {
77 | checksum = '0';
78 | }
79 | return (checksum + '' === chars[length - 1]);
80 |
81 | default:
82 | return false;
83 | }
84 | }
85 | };
86 | }(window.jQuery));
87 |
--------------------------------------------------------------------------------
/src/js/validator/isin.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.isin = $.extend($.fn.bootstrapValidator.i18n.isin || {}, {
3 | 'default': 'Please enter a valid ISIN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.isin = {
7 | // Available country codes
8 | // See http://isin.net/country-codes/
9 | COUNTRY_CODES: 'AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BQ|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CW|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SX|SK|SI|SB|SO|ZA|GS|SS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW',
10 |
11 | /**
12 | * Validate an ISIN (International Securities Identification Number)
13 | * Examples:
14 | * - Valid: US0378331005, AU0000XVGZA3, GB0002634946
15 | * - Invalid: US0378331004, AA0000XVGZA3
16 | *
17 | * @see http://en.wikipedia.org/wiki/International_Securities_Identifying_Number
18 | * @param {BootstrapValidator} validator The validator plugin instance
19 | * @param {jQuery} $field Field element
20 | * @param {Object} options Can consist of the following keys:
21 | * - message: The invalid message
22 | * @returns {Boolean}
23 | */
24 | validate: function(validator, $field, options) {
25 | var value = $field.val();
26 | if (value === '') {
27 | return true;
28 | }
29 |
30 | value = value.toUpperCase();
31 | var regex = new RegExp('^(' + this.COUNTRY_CODES + ')[0-9A-Z]{10}$');
32 | if (!regex.test(value)) {
33 | return false;
34 | }
35 |
36 | var converted = '',
37 | length = value.length;
38 | // Convert letters to number
39 | for (var i = 0; i < length - 1; i++) {
40 | var c = value.charCodeAt(i);
41 | converted += ((c > 57) ? (c - 55).toString() : value.charAt(i));
42 | }
43 |
44 | var digits = '',
45 | n = converted.length,
46 | group = (n % 2 !== 0) ? 0 : 1;
47 | for (i = 0; i < n; i++) {
48 | digits += (parseInt(converted[i], 10) * ((i % 2) === group ? 2 : 1) + '');
49 | }
50 |
51 | var sum = 0;
52 | for (i = 0; i < digits.length; i++) {
53 | sum += parseInt(digits.charAt(i), 10);
54 | }
55 | sum = (10 - (sum % 10)) % 10;
56 | return sum + '' === value.charAt(length - 1);
57 | }
58 | };
59 | }(window.jQuery));
60 |
--------------------------------------------------------------------------------
/src/js/validator/ismn.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.ismn = $.extend($.fn.bootstrapValidator.i18n.ismn || {}, {
3 | 'default': 'Please enter a valid ISMN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.ismn = {
7 | /**
8 | * Validate ISMN (International Standard Music Number)
9 | * Examples:
10 | * - Valid: M230671187, 979-0-0601-1561-5, 979 0 3452 4680 5, 9790060115615
11 | * - Invalid: 9790060115614
12 | *
13 | * @see http://en.wikipedia.org/wiki/International_Standard_Music_Number
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | // Groups are separated by a hyphen or a space
27 | var type;
28 | switch (true) {
29 | case /^M\d{9}$/.test(value):
30 | case /^M-\d{4}-\d{4}-\d{1}$/.test(value):
31 | case /^M\s\d{4}\s\d{4}\s\d{1}$/.test(value):
32 | type = 'ISMN10';
33 | break;
34 | case /^9790\d{9}$/.test(value):
35 | case /^979-0-\d{4}-\d{4}-\d{1}$/.test(value):
36 | case /^979\s0\s\d{4}\s\d{4}\s\d{1}$/.test(value):
37 | type = 'ISMN13';
38 | break;
39 | default:
40 | return false;
41 | }
42 |
43 | if ('ISMN10' === type) {
44 | value = '9790' + value.substr(1);
45 | }
46 |
47 | // Replace all special characters except digits
48 | value = value.replace(/[^0-9]/gi, '');
49 | var length = value.length,
50 | sum = 0,
51 | weight = [1, 3];
52 | for (var i = 0; i < length - 1; i++) {
53 | sum += parseInt(value.charAt(i), 10) * weight[i % 2];
54 | }
55 | sum = 10 - sum % 10;
56 | return (sum + '' === value.charAt(length - 1));
57 | }
58 | };
59 | }(window.jQuery));
60 |
--------------------------------------------------------------------------------
/src/js/validator/issn.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.issn = $.extend($.fn.bootstrapValidator.i18n.issn || {}, {
3 | 'default': 'Please enter a valid ISSN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.issn = {
7 | /**
8 | * Validate ISSN (International Standard Serial Number)
9 | * Examples:
10 | * - Valid: 0378-5955, 0024-9319, 0032-1478
11 | * - Invalid: 0032-147X
12 | *
13 | * @see http://en.wikipedia.org/wiki/International_Standard_Serial_Number
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | // Groups are separated by a hyphen or a space
27 | if (!/^\d{4}\-\d{3}[\dX]$/.test(value)) {
28 | return false;
29 | }
30 |
31 | // Replace all special characters except digits and X
32 | value = value.replace(/[^0-9X]/gi, '');
33 | var chars = value.split(''),
34 | length = chars.length,
35 | sum = 0;
36 |
37 | if (chars[7] === 'X') {
38 | chars[7] = 10;
39 | }
40 | for (var i = 0; i < length; i++) {
41 | sum += parseInt(chars[i], 10) * (8 - i);
42 | }
43 | return (sum % 11 === 0);
44 | }
45 | };
46 | }(window.jQuery));
47 |
--------------------------------------------------------------------------------
/src/js/validator/lessThan.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.lessThan = $.extend($.fn.bootstrapValidator.i18n.lessThan || {}, {
3 | 'default': 'Please enter a value less than or equal to %s',
4 | notInclusive: 'Please enter a value less than %s'
5 | });
6 |
7 | $.fn.bootstrapValidator.validators.lessThan = {
8 | html5Attributes: {
9 | message: 'message',
10 | value: 'value',
11 | inclusive: 'inclusive'
12 | },
13 |
14 | enableByHtml5: function($field) {
15 | var type = $field.attr('type'),
16 | max = $field.attr('max');
17 | if (max && type !== 'date') {
18 | return {
19 | value: max
20 | };
21 | }
22 |
23 | return false;
24 | },
25 |
26 | /**
27 | * Return true if the input value is less than or equal to given number
28 | *
29 | * @param {BootstrapValidator} validator The validator plugin instance
30 | * @param {jQuery} $field Field element
31 | * @param {Object} options Can consist of the following keys:
32 | * - value: The number used to compare to. It can be
33 | * - A number
34 | * - Name of field which its value defines the number
35 | * - Name of callback function that returns the number
36 | * - A callback function that returns the number
37 | *
38 | * - inclusive [optional]: Can be true or false. Default is true
39 | * - message: The invalid message
40 | * @returns {Boolean|Object}
41 | */
42 | validate: function(validator, $field, options) {
43 | var value = $field.val();
44 | if (value === '') {
45 | return true;
46 | }
47 |
48 | value = this._format(value);
49 | if (!$.isNumeric(value)) {
50 | return false;
51 | }
52 |
53 | var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
54 | compareToValue = this._format(compareTo);
55 |
56 | value = parseFloat(value);
57 | return (options.inclusive === true || options.inclusive === undefined)
58 | ? {
59 | valid: value <= compareToValue,
60 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.lessThan['default'], compareTo)
61 | }
62 | : {
63 | valid: value < compareToValue,
64 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.lessThan.notInclusive, compareTo)
65 | };
66 | },
67 |
68 | _format: function(value) {
69 | return (value + '').replace(',', '.');
70 | }
71 | };
72 | }(window.jQuery));
73 |
--------------------------------------------------------------------------------
/src/js/validator/mac.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.mac = $.extend($.fn.bootstrapValidator.i18n.mac || {}, {
3 | 'default': 'Please enter a valid MAC address'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.mac = {
7 | /**
8 | * Return true if the input value is a MAC address.
9 | *
10 | * @param {BootstrapValidator} validator The validator plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} options Can consist of the following keys:
13 | * - message: The invalid message
14 | * @returns {Boolean}
15 | */
16 | validate: function(validator, $field, options) {
17 | var value = $field.val();
18 | if (value === '') {
19 | return true;
20 | }
21 |
22 | return /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/.test(value);
23 | }
24 | };
25 | }(window.jQuery));
26 |
--------------------------------------------------------------------------------
/src/js/validator/meid.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.meid = $.extend($.fn.bootstrapValidator.i18n.meid || {}, {
3 | 'default': 'Please enter a valid MEID number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.meid = {
7 | /**
8 | * Validate MEID (Mobile Equipment Identifier)
9 | * Examples:
10 | * - Valid: 293608736500703710, 29360-87365-0070-3710, AF0123450ABCDE, AF-012345-0ABCDE
11 | * - Invalid: 2936087365007037101
12 | *
13 | * @see http://en.wikipedia.org/wiki/Mobile_equipment_identifier
14 | * @param {BootstrapValidator} validator The validator plugin instance
15 | * @param {jQuery} $field Field element
16 | * @param {Object} options Can consist of the following keys:
17 | * - message: The invalid message
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var value = $field.val();
22 | if (value === '') {
23 | return true;
24 | }
25 |
26 | switch (true) {
27 | // 14 digit hex representation (no check digit)
28 | case /^[0-9A-F]{15}$/i.test(value):
29 | // 14 digit hex representation + dashes or spaces (no check digit)
30 | case /^[0-9A-F]{2}[- ][0-9A-F]{6}[- ][0-9A-F]{6}[- ][0-9A-F]$/i.test(value):
31 | // 18 digit decimal representation (no check digit)
32 | case /^\d{19}$/.test(value):
33 | // 18 digit decimal representation + dashes or spaces (no check digit)
34 | case /^\d{5}[- ]\d{5}[- ]\d{4}[- ]\d{4}[- ]\d$/.test(value):
35 | // Grab the check digit
36 | var cd = value.charAt(value.length - 1);
37 |
38 | // Strip any non-hex chars
39 | value = value.replace(/[- ]/g, '');
40 |
41 | // If it's all digits, luhn base 10 is used
42 | if (value.match(/^\d*$/i)) {
43 | return $.fn.bootstrapValidator.helpers.luhn(value);
44 | }
45 |
46 | // Strip the check digit
47 | value = value.slice(0, -1);
48 |
49 | // Get every other char, and double it
50 | var cdCalc = '';
51 | for (var i = 1; i <= 13; i += 2) {
52 | cdCalc += (parseInt(value.charAt(i), 16) * 2).toString(16);
53 | }
54 |
55 | // Get the sum of each char in the string
56 | var sum = 0;
57 | for (i = 0; i < cdCalc.length; i++) {
58 | sum += parseInt(cdCalc.charAt(i), 16);
59 | }
60 |
61 | // If the last digit of the calc is 0, the check digit is 0
62 | return (sum % 10 === 0)
63 | ? (cd === '0')
64 | // Subtract it from the next highest 10s number (64 goes to 70) and subtract the sum
65 | // Double it and turn it into a hex char
66 | : (cd === ((Math.floor((sum + 10) / 10) * 10 - sum) * 2).toString(16));
67 |
68 | // 14 digit hex representation (no check digit)
69 | case /^[0-9A-F]{14}$/i.test(value):
70 | // 14 digit hex representation + dashes or spaces (no check digit)
71 | case /^[0-9A-F]{2}[- ][0-9A-F]{6}[- ][0-9A-F]{6}$/i.test(value):
72 | // 18 digit decimal representation (no check digit)
73 | case /^\d{18}$/.test(value):
74 | // 18 digit decimal representation + dashes or spaces (no check digit)
75 | case /^\d{5}[- ]\d{5}[- ]\d{4}[- ]\d{4}$/.test(value):
76 | return true;
77 |
78 | default:
79 | return false;
80 | }
81 | }
82 | };
83 | }(window.jQuery));
84 |
--------------------------------------------------------------------------------
/src/js/validator/notEmpty.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.notEmpty = $.extend($.fn.bootstrapValidator.i18n.notEmpty || {}, {
3 | 'default': 'Please enter a value'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.notEmpty = {
7 | enableByHtml5: function($field) {
8 | var required = $field.attr('required') + '';
9 | return ('required' === required || 'true' === required);
10 | },
11 |
12 | /**
13 | * Check if input value is empty or not
14 | *
15 | * @param {BootstrapValidator} validator The validator plugin instance
16 | * @param {jQuery} $field Field element
17 | * @param {Object} options
18 | * @returns {Boolean}
19 | */
20 | validate: function(validator, $field, options) {
21 | var type = $field.attr('type');
22 | if ('radio' === type || 'checkbox' === type) {
23 | return validator
24 | .getFieldElements($field.attr('data-bv-field'))
25 | .filter(':checked')
26 | .length > 0;
27 | }
28 |
29 | if ('number' === type && $field.get(0).validity && $field.get(0).validity.badInput === true) {
30 | return true;
31 | }
32 |
33 | return $.trim($field.val()) !== '';
34 | }
35 | };
36 | }(window.jQuery));
37 |
--------------------------------------------------------------------------------
/src/js/validator/numeric.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.numeric = $.extend($.fn.bootstrapValidator.i18n.numeric || {}, {
3 | 'default': 'Please enter a valid float number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.numeric = {
7 | html5Attributes: {
8 | message: 'message',
9 | separator: 'separator'
10 | },
11 |
12 | enableByHtml5: function($field) {
13 | return ('number' === $field.attr('type')) && ($field.attr('step') !== undefined) && ($field.attr('step') % 1 !== 0);
14 | },
15 |
16 | /**
17 | * Validate decimal number
18 | *
19 | * @param {BootstrapValidator} validator The validator plugin instance
20 | * @param {jQuery} $field Field element
21 | * @param {Object} options Consist of key:
22 | * - message: The invalid message
23 | * - separator: The decimal separator. Can be "." (default), ","
24 | * @returns {Boolean}
25 | */
26 | validate: function(validator, $field, options) {
27 | if (this.enableByHtml5($field) && $field.get(0).validity && $field.get(0).validity.badInput === true) {
28 | return false;
29 | }
30 |
31 | var value = $field.val();
32 | if (value === '') {
33 | return true;
34 | }
35 | var separator = options.separator || '.';
36 | if (separator !== '.') {
37 | value = value.replace(separator, '.');
38 | }
39 |
40 | return !isNaN(parseFloat(value)) && isFinite(value);
41 | }
42 | };
43 | }(window.jQuery));
44 |
--------------------------------------------------------------------------------
/src/js/validator/regexp.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.regexp = $.extend($.fn.bootstrapValidator.i18n.regexp || {}, {
3 | 'default': 'Please enter a value matching the pattern'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.regexp = {
7 | html5Attributes: {
8 | message: 'message',
9 | regexp: 'regexp'
10 | },
11 |
12 | enableByHtml5: function($field) {
13 | var pattern = $field.attr('pattern');
14 | if (pattern) {
15 | return {
16 | regexp: pattern
17 | };
18 | }
19 |
20 | return false;
21 | },
22 |
23 | /**
24 | * Check if the element value matches given regular expression
25 | *
26 | * @param {BootstrapValidator} validator The validator plugin instance
27 | * @param {jQuery} $field Field element
28 | * @param {Object} options Consists of the following key:
29 | * - regexp: The regular expression you need to check
30 | * @returns {Boolean}
31 | */
32 | validate: function(validator, $field, options) {
33 | var value = $field.val();
34 | if (value === '') {
35 | return true;
36 | }
37 |
38 | var regexp = ('string' === typeof options.regexp) ? new RegExp(options.regexp) : options.regexp;
39 | return regexp.test(value);
40 | }
41 | };
42 | }(window.jQuery));
43 |
--------------------------------------------------------------------------------
/src/js/validator/remote.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.remote = $.extend($.fn.bootstrapValidator.i18n.remote || {}, {
3 | 'default': 'Please enter a valid value'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.remote = {
7 | html5Attributes: {
8 | message: 'message',
9 | name: 'name',
10 | type: 'type',
11 | url: 'url',
12 | data: 'data',
13 | delay: 'delay'
14 | },
15 |
16 | /**
17 | * Destroy the timer when destroying the bootstrapValidator (using validator.destroy() method)
18 | */
19 | destroy: function(validator, $field, options) {
20 | if ($field.data('bv.remote.timer')) {
21 | clearTimeout($field.data('bv.remote.timer'));
22 | $field.removeData('bv.remote.timer');
23 | }
24 | },
25 |
26 | /**
27 | * Request a remote server to check the input value
28 | *
29 | * @param {BootstrapValidator} validator Plugin instance
30 | * @param {jQuery} $field Field element
31 | * @param {Object} options Can consist of the following keys:
32 | * - url {String|Function}
33 | * - type {String} [optional] Can be GET or POST (default)
34 | * - data {Object|Function} [optional]: By default, it will take the value
35 | * {
36 | * :
37 | * }
38 | * - delay
39 | * - name {String} [optional]: Override the field name for the request.
40 | * - message: The invalid message
41 | * - headers: Additional headers
42 | * @returns {Deferred}
43 | */
44 | validate: function(validator, $field, options) {
45 | var value = $field.val(),
46 | dfd = new $.Deferred();
47 | if (value === '') {
48 | dfd.resolve($field, 'remote', { valid: true });
49 | return dfd;
50 | }
51 |
52 | var name = $field.attr('data-bv-field'),
53 | data = options.data || {},
54 | url = options.url,
55 | type = options.type || 'GET',
56 | headers = options.headers || {};
57 |
58 | // Support dynamic data
59 | if ('function' === typeof data) {
60 | data = data.call(this, validator);
61 | }
62 |
63 | // Parse string data from HTML5 attribute
64 | if ('string' === typeof data) {
65 | data = JSON.parse(data);
66 | }
67 |
68 | // Support dynamic url
69 | if ('function' === typeof url) {
70 | url = url.call(this, validator);
71 | }
72 |
73 | data[options.name || name] = value;
74 | function runCallback() {
75 | var xhr = $.ajax({
76 | type: type,
77 | headers: headers,
78 | url: url,
79 | dataType: 'json',
80 | data: data
81 | });
82 | xhr.then(function(response) {
83 | response.valid = response.valid === true || response.valid === 'true';
84 | dfd.resolve($field, 'remote', response);
85 | });
86 |
87 | dfd.fail(function() {
88 | xhr.abort();
89 | });
90 |
91 | return dfd;
92 | }
93 |
94 | if (options.delay) {
95 | // Since the form might have multiple fields with the same name
96 | // I have to attach the timer to the field element
97 | if ($field.data('bv.remote.timer')) {
98 | clearTimeout($field.data('bv.remote.timer'));
99 | }
100 |
101 | $field.data('bv.remote.timer', setTimeout(runCallback, options.delay));
102 | return dfd;
103 | } else {
104 | return runCallback();
105 | }
106 | }
107 | };
108 | }(window.jQuery));
109 |
--------------------------------------------------------------------------------
/src/js/validator/rtn.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.rtn = $.extend($.fn.bootstrapValidator.i18n.rtn || {}, {
3 | 'default': 'Please enter a valid RTN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.rtn = {
7 | /**
8 | * Validate a RTN (Routing transit number)
9 | * Examples:
10 | * - Valid: 021200025, 789456124
11 | *
12 | * @see http://en.wikipedia.org/wiki/Routing_transit_number
13 | * @param {BootstrapValidator} validator The validator plugin instance
14 | * @param {jQuery} $field Field element
15 | * @param {Object} options Can consist of the following keys:
16 | * - message: The invalid message
17 | * @returns {Boolean}
18 | */
19 | validate: function(validator, $field, options) {
20 | var value = $field.val();
21 | if (value === '') {
22 | return true;
23 | }
24 |
25 | if (!/^\d{9}$/.test(value)) {
26 | return false;
27 | }
28 |
29 | var sum = 0;
30 | for (var i = 0; i < value.length; i += 3) {
31 | sum += parseInt(value.charAt(i), 10) * 3
32 | + parseInt(value.charAt(i + 1), 10) * 7
33 | + parseInt(value.charAt(i + 2), 10);
34 | }
35 | return (sum !== 0 && sum % 10 === 0);
36 | }
37 | };
38 | }(window.jQuery));
39 |
--------------------------------------------------------------------------------
/src/js/validator/sedol.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.sedol = $.extend($.fn.bootstrapValidator.i18n.sedol || {}, {
3 | 'default': 'Please enter a valid SEDOL number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.sedol = {
7 | /**
8 | * Validate a SEDOL (Stock Exchange Daily Official List)
9 | * Examples:
10 | * - Valid: 0263494, B0WNLY7
11 | *
12 | * @see http://en.wikipedia.org/wiki/SEDOL
13 | * @param {BootstrapValidator} validator The validator plugin instance
14 | * @param {jQuery} $field Field element
15 | * @param {Object} options Can consist of the following keys:
16 | * - message: The invalid message
17 | * @returns {Boolean}
18 | */
19 | validate: function(validator, $field, options) {
20 | var value = $field.val();
21 | if (value === '') {
22 | return true;
23 | }
24 |
25 | value = value.toUpperCase();
26 | if (!/^[0-9A-Z]{7}$/.test(value)) {
27 | return false;
28 | }
29 |
30 | var sum = 0,
31 | weight = [1, 3, 1, 7, 3, 9, 1],
32 | length = value.length;
33 | for (var i = 0; i < length - 1; i++) {
34 | sum += weight[i] * parseInt(value.charAt(i), 36);
35 | }
36 | sum = (10 - sum % 10) % 10;
37 | return sum + '' === value.charAt(length - 1);
38 | }
39 | };
40 | }(window.jQuery));
41 |
--------------------------------------------------------------------------------
/src/js/validator/siren.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.siren = $.extend($.fn.bootstrapValidator.i18n.siren || {}, {
3 | 'default': 'Please enter a valid SIREN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.siren = {
7 | /**
8 | * Check if a string is a siren number
9 | *
10 | * @param {BootstrapValidator} validator The validator plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} options Consist of key:
13 | * - message: The invalid message
14 | * @returns {Boolean}
15 | */
16 | validate: function(validator, $field, options) {
17 | var value = $field.val();
18 | if (value === '') {
19 | return true;
20 | }
21 |
22 | if (!/^\d{9}$/.test(value)) {
23 | return false;
24 | }
25 | return $.fn.bootstrapValidator.helpers.luhn(value);
26 | }
27 | };
28 | }(window.jQuery));
29 |
--------------------------------------------------------------------------------
/src/js/validator/siret.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.siret = $.extend($.fn.bootstrapValidator.i18n.siret || {}, {
3 | 'default': 'Please enter a valid SIRET number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.siret = {
7 | /**
8 | * Check if a string is a siret number
9 | *
10 | * @param {BootstrapValidator} validator The validator plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} options Consist of key:
13 | * - message: The invalid message
14 | * @returns {Boolean}
15 | */
16 | validate: function(validator, $field, options) {
17 | var value = $field.val();
18 | if (value === '') {
19 | return true;
20 | }
21 |
22 | var sum = 0,
23 | length = value.length,
24 | tmp;
25 | for (var i = 0; i < length; i++) {
26 | tmp = parseInt(value.charAt(i), 10);
27 | if ((i % 2) === 0) {
28 | tmp = tmp * 2;
29 | if (tmp > 9) {
30 | tmp -= 9;
31 | }
32 | }
33 | sum += tmp;
34 | }
35 | return (sum % 10 === 0);
36 | }
37 | };
38 | }(window.jQuery));
39 |
--------------------------------------------------------------------------------
/src/js/validator/step.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.step = $.extend($.fn.bootstrapValidator.i18n.step || {}, {
3 | 'default': 'Please enter a valid step of %s'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.step = {
7 | html5Attributes: {
8 | message: 'message',
9 | base: 'baseValue',
10 | step: 'step'
11 | },
12 |
13 | /**
14 | * Return true if the input value is valid step one
15 | *
16 | * @param {BootstrapValidator} validator The validator plugin instance
17 | * @param {jQuery} $field Field element
18 | * @param {Object} options Can consist of the following keys:
19 | * - baseValue: The base value
20 | * - step: The step
21 | * - message: The invalid message
22 | * @returns {Boolean|Object}
23 | */
24 | validate: function(validator, $field, options) {
25 | var value = $field.val();
26 | if (value === '') {
27 | return true;
28 | }
29 |
30 | options = $.extend({}, { baseValue: 0, step: 1 }, options);
31 | value = parseFloat(value);
32 | if (!$.isNumeric(value)) {
33 | return false;
34 | }
35 |
36 | var round = function(x, precision) {
37 | var m = Math.pow(10, precision);
38 | x = x * m;
39 | var sign = (x > 0) | -(x < 0),
40 | isHalf = (x % 1 === 0.5 * sign);
41 | if (isHalf) {
42 | return (Math.floor(x) + (sign > 0)) / m;
43 | } else {
44 | return Math.round(x) / m;
45 | }
46 | },
47 | floatMod = function(x, y) {
48 | if (y === 0.0) {
49 | return 1.0;
50 | }
51 | var dotX = (x + '').split('.'),
52 | dotY = (y + '').split('.'),
53 | precision = ((dotX.length === 1) ? 0 : dotX[1].length) + ((dotY.length === 1) ? 0 : dotY[1].length);
54 | return round(x - y * Math.floor(x / y), precision);
55 | };
56 |
57 | var mod = floatMod(value - options.baseValue, options.step);
58 | return {
59 | valid: mod === 0.0 || mod === options.step,
60 | message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.step['default'], [options.step])
61 | };
62 | }
63 | };
64 | }(window.jQuery));
65 |
--------------------------------------------------------------------------------
/src/js/validator/stringCase.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.stringCase = $.extend($.fn.bootstrapValidator.i18n.stringCase || {}, {
3 | 'default': 'Please enter only lowercase characters',
4 | upper: 'Please enter only uppercase characters'
5 | });
6 |
7 | $.fn.bootstrapValidator.validators.stringCase = {
8 | html5Attributes: {
9 | message: 'message',
10 | 'case': 'case'
11 | },
12 |
13 | /**
14 | * Check if a string is a lower or upper case one
15 | *
16 | * @param {BootstrapValidator} validator The validator plugin instance
17 | * @param {jQuery} $field Field element
18 | * @param {Object} options Consist of key:
19 | * - message: The invalid message
20 | * - case: Can be 'lower' (default) or 'upper'
21 | * @returns {Object}
22 | */
23 | validate: function(validator, $field, options) {
24 | var value = $field.val();
25 | if (value === '') {
26 | return true;
27 | }
28 |
29 | var stringCase = (options['case'] || 'lower').toLowerCase();
30 | return {
31 | valid: ('upper' === stringCase) ? value === value.toUpperCase() : value === value.toLowerCase(),
32 | message: options.message || (('upper' === stringCase) ? $.fn.bootstrapValidator.i18n.stringCase.upper : $.fn.bootstrapValidator.i18n.stringCase['default'])
33 | };
34 | }
35 | };
36 | }(window.jQuery));
37 |
--------------------------------------------------------------------------------
/src/js/validator/stringLength.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.stringLength = $.extend($.fn.bootstrapValidator.i18n.stringLength || {}, {
3 | 'default': 'Please enter a value with valid length',
4 | less: 'Please enter less than %s characters',
5 | more: 'Please enter more than %s characters',
6 | between: 'Please enter value between %s and %s characters long'
7 | });
8 |
9 | $.fn.bootstrapValidator.validators.stringLength = {
10 | html5Attributes: {
11 | message: 'message',
12 | min: 'min',
13 | max: 'max',
14 | trim: 'trim',
15 | utf8bytes: 'utf8Bytes'
16 | },
17 |
18 | enableByHtml5: function($field) {
19 | var options = {},
20 | maxLength = $field.attr('maxlength'),
21 | minLength = $field.attr('minlength');
22 | if (maxLength) {
23 | options.max = parseInt(maxLength, 10);
24 | }
25 | if (minLength) {
26 | options.min = parseInt(minLength, 10);
27 | }
28 |
29 | return $.isEmptyObject(options) ? false : options;
30 | },
31 |
32 | /**
33 | * Check if the length of element value is less or more than given number
34 | *
35 | * @param {BootstrapValidator} validator The validator plugin instance
36 | * @param {jQuery} $field Field element
37 | * @param {Object} options Consists of following keys:
38 | * - min
39 | * - max
40 | * At least one of two keys is required
41 | * The min, max keys define the number which the field value compares to. min, max can be
42 | * - A number
43 | * - Name of field which its value defines the number
44 | * - Name of callback function that returns the number
45 | * - A callback function that returns the number
46 | *
47 | * - message: The invalid message
48 | * - trim: Indicate the length will be calculated after trimming the value or not. It is false, by default
49 | * - utf8bytes: Evaluate string length in UTF-8 bytes, default to false
50 | * @returns {Object}
51 | */
52 | validate: function(validator, $field, options) {
53 | var value = $field.val();
54 | if (options.trim === true || options.trim === 'true') {
55 | value = $.trim(value);
56 | }
57 |
58 | if (value === '') {
59 | return true;
60 | }
61 |
62 | var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
63 | max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
64 | // Credit to http://stackoverflow.com/a/23329386 (@lovasoa) for UTF-8 byte length code
65 | utf8Length = function(str) {
66 | var s = str.length;
67 | for (var i = str.length - 1; i >= 0; i--) {
68 | var code = str.charCodeAt(i);
69 | if (code > 0x7f && code <= 0x7ff) {
70 | s++;
71 | } else if (code > 0x7ff && code <= 0xffff) {
72 | s += 2;
73 | }
74 | if (code >= 0xDC00 && code <= 0xDFFF) {
75 | i--;
76 | }
77 | }
78 | return s;
79 | },
80 | length = options.utf8Bytes ? utf8Length(value) : value.length,
81 | isValid = true,
82 | message = options.message || $.fn.bootstrapValidator.i18n.stringLength['default'];
83 |
84 | if ((min && length < parseInt(min, 10)) || (max && length > parseInt(max, 10))) {
85 | isValid = false;
86 | }
87 |
88 | switch (true) {
89 | case (!!min && !!max):
90 | message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.stringLength.between, [parseInt(min, 10), parseInt(max, 10)]);
91 | break;
92 |
93 | case (!!min):
94 | message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.stringLength.more, parseInt(min, 10));
95 | break;
96 |
97 | case (!!max):
98 | message = $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.stringLength.less, parseInt(max, 10));
99 | break;
100 |
101 | default:
102 | break;
103 | }
104 |
105 | return { valid: isValid, message: message };
106 | }
107 | };
108 | }(window.jQuery));
109 |
--------------------------------------------------------------------------------
/src/js/validator/uri.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.uri = $.extend($.fn.bootstrapValidator.i18n.uri || {}, {
3 | 'default': 'Please enter a valid URI'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.uri = {
7 | html5Attributes: {
8 | message: 'message',
9 | allowlocal: 'allowLocal',
10 | protocol: 'protocol'
11 | },
12 |
13 | enableByHtml5: function($field) {
14 | return ('url' === $field.attr('type'));
15 | },
16 |
17 | /**
18 | * Return true if the input value is a valid URL
19 | *
20 | * @param {BootstrapValidator} validator The validator plugin instance
21 | * @param {jQuery} $field Field element
22 | * @param {Object} options
23 | * - message: The error message
24 | * - allowLocal: Allow the private and local network IP. Default to false
25 | * - protocol: The protocols, separated by a comma. Default to "http, https, ftp"
26 | * @returns {Boolean}
27 | */
28 | validate: function(validator, $field, options) {
29 | var value = $field.val();
30 | if (value === '') {
31 | return true;
32 | }
33 |
34 | // Credit to https://gist.github.com/dperini/729294
35 | //
36 | // Regular Expression for URL validation
37 | //
38 | // Author: Diego Perini
39 | // Updated: 2010/12/05
40 | //
41 | // the regular expression composed & commented
42 | // could be easily tweaked for RFC compliance,
43 | // it was expressly modified to fit & satisfy
44 | // these test for an URL shortener:
45 | //
46 | // http://mathiasbynens.be/demo/url-regex
47 | //
48 | // Notes on possible differences from a standard/generic validation:
49 | //
50 | // - utf-8 char class take in consideration the full Unicode range
51 | // - TLDs are mandatory unless `allowLocal` is true
52 | // - protocols have been restricted to ftp, http and https only as requested
53 | //
54 | // Changes:
55 | //
56 | // - IP address dotted notation validation, range: 1.0.0.0 - 223.255.255.255
57 | // first and last IP address of each class is considered invalid
58 | // (since they are broadcast/network addresses)
59 | //
60 | // - Added exclusion of private, reserved and/or local networks ranges
61 | // unless `allowLocal` is true
62 | //
63 | // - Added possibility of choosing a custom protocol
64 | //
65 | var allowLocal = options.allowLocal === true || options.allowLocal === 'true',
66 | protocol = (options.protocol || 'http, https, ftp').split(',').join('|').replace(/\s/g, ''),
67 | urlExp = new RegExp(
68 | "^" +
69 | // protocol identifier
70 | "(?:(?:" + protocol + ")://)" +
71 | // user:pass authentication
72 | "(?:\\S+(?::\\S*)?@)?" +
73 | "(?:" +
74 | // IP address exclusion
75 | // private & local networks
76 | (allowLocal
77 | ? ''
78 | : ("(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
79 | "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
80 | "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})")) +
81 | // IP address dotted notation octets
82 | // excludes loopback network 0.0.0.0
83 | // excludes reserved space >= 224.0.0.0
84 | // excludes network & broadcast addresses
85 | // (first & last IP address of each class)
86 | "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
87 | "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
88 | "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
89 | "|" +
90 | // host name
91 | "(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)" +
92 | // domain name
93 | "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*" +
94 | // TLD identifier
95 | "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
96 | // Allow intranet sites (no TLD) if `allowLocal` is true
97 | (allowLocal ? '?' : '') +
98 | ")" +
99 | // port number
100 | "(?::\\d{2,5})?" +
101 | // resource path
102 | "(?:/[^\\s]*)?" +
103 | "$", "i"
104 | );
105 |
106 | return urlExp.test(value);
107 | }
108 | };
109 | }(window.jQuery));
110 |
--------------------------------------------------------------------------------
/src/js/validator/uuid.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.uuid = $.extend($.fn.bootstrapValidator.i18n.uuid || {}, {
3 | 'default': 'Please enter a valid UUID number',
4 | version: 'Please enter a valid UUID version %s number'
5 | });
6 |
7 | $.fn.bootstrapValidator.validators.uuid = {
8 | html5Attributes: {
9 | message: 'message',
10 | version: 'version'
11 | },
12 |
13 | /**
14 | * Return true if and only if the input value is a valid UUID string
15 | *
16 | * @see http://en.wikipedia.org/wiki/Universally_unique_identifier
17 | * @param {BootstrapValidator} validator The validator plugin instance
18 | * @param {jQuery} $field Field element
19 | * @param {Object} options Consist of key:
20 | * - message: The invalid message
21 | * - version: Can be 3, 4, 5, null
22 | * @returns {Boolean|Object}
23 | */
24 | validate: function(validator, $field, options) {
25 | var value = $field.val();
26 | if (value === '') {
27 | return true;
28 | }
29 |
30 | // See the format at http://en.wikipedia.org/wiki/Universally_unique_identifier#Variants_and_versions
31 | var patterns = {
32 | '3': /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
33 | '4': /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
34 | '5': /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
35 | all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
36 | },
37 | version = options.version ? (options.version + '') : 'all';
38 | return {
39 | valid: (null === patterns[version]) ? true : patterns[version].test(value),
40 | message: options.version
41 | ? $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.uuid.version, options.version)
42 | : (options.message || $.fn.bootstrapValidator.i18n.uuid['default'])
43 | };
44 | }
45 | };
46 | }(window.jQuery));
47 |
--------------------------------------------------------------------------------
/src/js/validator/vin.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.bootstrapValidator.i18n.vin = $.extend($.fn.bootstrapValidator.i18n.vin || {}, {
3 | 'default': 'Please enter a valid VIN number'
4 | });
5 |
6 | $.fn.bootstrapValidator.validators.vin = {
7 | /**
8 | * Validate an US VIN (Vehicle Identification Number)
9 | *
10 | * @param {BootstrapValidator} validator The validator plugin instance
11 | * @param {jQuery} $field Field element
12 | * @param {Object} options Consist of key:
13 | * - message: The invalid message
14 | * @returns {Boolean}
15 | */
16 | validate: function(validator, $field, options) {
17 | var value = $field.val();
18 | if (value === '') {
19 | return true;
20 | }
21 |
22 | // Don't accept I, O, Q characters
23 | if (!/^[a-hj-npr-z0-9]{8}[0-9xX][a-hj-npr-z0-9]{8}$/i.test(value)) {
24 | return false;
25 | }
26 |
27 | value = value.toUpperCase();
28 | var chars = {
29 | A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8,
30 | J: 1, K: 2, L: 3, M: 4, N: 5, P: 7, R: 9,
31 | S: 2, T: 3, U: 4, V: 5, W: 6, X: 7, Y: 8, Z: 9,
32 | '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '0': 0
33 | },
34 | weights = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2],
35 | sum = 0,
36 | length = value.length;
37 | for (var i = 0; i < length; i++) {
38 | sum += chars[value.charAt(i) + ''] * weights[i];
39 | }
40 |
41 | var reminder = sum % 11;
42 | if (reminder === 10) {
43 | reminder = 'X';
44 | }
45 |
46 | return (reminder + '') === value.charAt(8);
47 | }
48 | };
49 | }(window.jQuery));
50 |
--------------------------------------------------------------------------------
/test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BootstrapValidator test suites
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/test/spec/api.js:
--------------------------------------------------------------------------------
1 | describe('api', function() {
2 | // Override the options
3 | $.extend($.fn.bootstrapValidator.DEFAULT_OPTIONS, {
4 | feedbackIcons: {
5 | valid: 'glyphicon glyphicon-ok',
6 | invalid: 'glyphicon glyphicon-remove',
7 | validating: 'glyphicon glyphicon-refresh'
8 | }
9 | });
10 |
11 | beforeEach(function() {
12 | $([
13 | ''
24 | ].join('\n')).appendTo('body');
25 |
26 | $('#apiForm').bootstrapValidator();
27 |
28 | this.bv = $('#apiForm').data('bootstrapValidator');
29 | this.$email = this.bv.getFieldElements('email');
30 | this.$note = $('#apiForm').find('input[name="note"]');
31 | });
32 |
33 | afterEach(function() {
34 | $('#apiForm').bootstrapValidator('destroy').remove();
35 | });
36 |
37 | it('revalidateField()', function() {
38 | this.$email.val('email@domain.com');
39 | this.bv.validate();
40 | expect(this.bv.isValidField('email')).toBeTruthy();
41 |
42 | this.$email.val('invalid#email.address');
43 | this.bv.revalidateField('email');
44 | expect(this.bv.isValidField(this.$email)).toEqual(false);
45 | });
46 |
47 | it('destroy()', function() {
48 | this.bv.destroy();
49 | expect($('#apiForm').data('bootstrapValidator')).toBeUndefined();
50 | expect($('#apiForm').find('i[data-bv-icon-for]').length).toEqual(0);
51 | expect($('#apiForm').find('.help-block[data-bv-for]').length).toEqual(0);
52 | expect($('#apiForm').find('.has-feedback').length).toEqual(0);
53 | expect($('#apiForm').find('.has-success').length).toEqual(0);
54 | expect($('#apiForm').find('.has-error').length).toEqual(0);
55 | expect($('#apiForm').find('[data-bv-field]').length).toEqual(0);
56 | });
57 |
58 | it('getOptions()', function() {
59 | // Form options
60 | expect(this.bv.getOptions().feedbackIcons.valid).toEqual('glyphicon glyphicon-ok');
61 |
62 | // Field options
63 | expect(this.bv.getOptions('username', 'stringlength')).toBeNull();
64 | expect(this.bv.getOptions('username', 'stringlength', 'min')).toBeNull();
65 |
66 | expect(this.bv.getOptions('username', 'stringLength')).toBeDefined();
67 | expect(this.bv.getOptions('username', 'stringLength', 'min')).toEqual('8');
68 | expect(this.bv.getOptions('username', 'stringlength', 'max')).toBeNull();
69 | });
70 |
71 | // #1014
72 | it('isValidField()', function() {
73 | this.$email.val('email@domain.com');
74 | this.bv.validate();
75 | expect(this.bv.isValidField(this.$note)).toBeTruthy();
76 | expect(this.bv.isValidField(this.$email)).toBeTruthy();
77 | });
78 |
79 | // #1014
80 | it('validateField()', function() {
81 | this.$email.val('email@domain.com');
82 | this.bv.validateField(this.$email);
83 | this.bv.validateField(this.$note);
84 | expect(this.bv.isValidField(this.$email)).toBeTruthy();
85 | expect(this.bv.isValidField(this.$note)).toBeTruthy();
86 | });
87 | });
88 |
--------------------------------------------------------------------------------
/test/spec/autoFocus.js:
--------------------------------------------------------------------------------
1 | describe('autoFocus', function() {
2 | beforeEach(function() {
3 | $([
4 | ''
15 | ].join('')).appendTo('body');
16 |
17 | this.bv = $('#autoFocusForm')
18 | .bootstrapValidator()
19 | .submit(function(e) {
20 | e.preventDefault();
21 | })
22 | .data('bootstrapValidator');
23 | this.$username = this.bv.getFieldElements('username');
24 | this.$email = this.bv.getFieldElements('email');
25 | });
26 |
27 | afterEach(function() {
28 | $('#autoFocusForm').bootstrapValidator('destroy').remove();
29 | });
30 |
31 | it('default option (autoFocus=true)', function() {
32 | $('#submitButton').click();
33 | expect(this.$username.is(':focus')).toBeTruthy();
34 | expect($(document.activeElement).attr('name')).toEqual('username');
35 |
36 | this.bv.resetForm();
37 | this.$username.val('user_name');
38 | this.$email.val('');
39 | $('#submitButton').click();
40 | expect(this.$email.is(':focus')).toBeTruthy();
41 | expect($(document.activeElement).attr('name')).toEqual('email');
42 | });
43 |
44 | it('set autoFocus=false for form', function() {
45 | $('#autoFocusForm')
46 | .bootstrapValidator('destroy')
47 | .bootstrapValidator({
48 | autoFocus: false
49 | });
50 | this.$username.val('');
51 | this.$email.val('invalid#email');
52 | $('#submitButton').click();
53 |
54 | expect(this.$username.is(':focus')).toBeFalsy();
55 | expect(this.$email.is(':focus')).toBeFalsy();
56 | });
57 |
58 | it('set autoFocus=false for all fields', function() {
59 | this.bv
60 | .addField('username', {
61 | autoFocus: false
62 | })
63 | .addField('email', {
64 | autoFocus: false
65 | });
66 | this.$username.val('user_name');
67 | this.$email.val('invalid#email');
68 | $('#submitButton').click();
69 |
70 | expect(this.$username.is(':focus')).toBeFalsy();
71 | expect(this.$email.is(':focus')).toBeFalsy();
72 | });
73 |
74 | it('set different autoFocus value for fields', function() {
75 | this.bv
76 | .addField('username', {
77 | autoFocus: false
78 | })
79 | .addField('email', {
80 | autoFocus: true
81 | });
82 | this.$username.val('');
83 | this.$email.val('invalid_email');
84 | $('#submitButton').click();
85 |
86 | expect(this.$username.is(':focus')).toBeFalsy();
87 | expect(this.$email.is(':focus')).toBeTruthy();
88 | expect($(document.activeElement).attr('name')).toEqual('email');
89 | });
90 | });
91 |
--------------------------------------------------------------------------------
/test/spec/dynamic.js:
--------------------------------------------------------------------------------
1 | describe('dynamic fields', function() {
2 | beforeEach(function() {
3 | $([
4 | ''
9 | ].join('\n')).appendTo('body');
10 |
11 | $('#dynamicForm').bootstrapValidator({
12 | fields: {
13 | fullName: {
14 | validators: {
15 | notEmpty: {
16 | message: 'The full name is required and cannot be empty'
17 | },
18 | stringLength: {
19 | min: 8,
20 | max: 40,
21 | message: 'The full name must be more than %s and less than %s characters long'
22 | },
23 | regexp: {
24 | enabled: false,
25 | regexp: /^[a-zA-Z\s]+$/,
26 | message: 'The full name can only consist of alphabetical, number, and space'
27 | }
28 | }
29 | },
30 | // #725: Note that the email field isn't available in the form yet
31 | email: {
32 | validators: {
33 | emailAddress: {
34 | message: 'The email address is not valid'
35 | }
36 | }
37 | }
38 | }
39 | });
40 |
41 | this.bv = $('#dynamicForm').data('bootstrapValidator');
42 | this.$fullName = this.bv.getFieldElements('fullName');
43 | });
44 |
45 | afterEach(function() {
46 | $('#dynamicForm').bootstrapValidator('destroy').remove();
47 | });
48 |
49 | // https://github.com/nghuuphuoc/bootstrapvalidator/pull/725
50 | it('adding field [does not exist but is already set in "fields" option]', function() {
51 | var $div = $('').addClass('form-group').appendTo($('#dynamicForm'));
52 | $email = $('')
53 | .attr('type', 'text')
54 | .addClass('form-control')
55 | .attr('name', 'email')
56 | .appendTo($div);
57 |
58 | this.bv.addField('email');
59 |
60 | this.$fullName.val('Phuoc Nguyen');
61 |
62 | $email.val('not valid@email');
63 | this.bv.validate();
64 | expect(this.bv.isValidField('email')).toBeFalsy();
65 | expect(this.bv.isValid()).toBeFalsy();
66 |
67 | this.bv.resetForm();
68 | $email.val('valid@email.com');
69 | this.bv.validate();
70 | expect(this.bv.isValidField('email')).toBeTruthy();
71 | expect(this.bv.isValid()).toBeTruthy();
72 | });
73 | });
74 |
--------------------------------------------------------------------------------
/test/spec/enable.js:
--------------------------------------------------------------------------------
1 | describe('enable validators', function() {
2 | beforeEach(function() {
3 | $([
4 | ''
9 | ].join('\n')).appendTo('body');
10 |
11 | $('#enableForm').bootstrapValidator({
12 | fields: {
13 | fullName: {
14 | validators: {
15 | notEmpty: {
16 | message: 'The full name is required and cannot be empty'
17 | },
18 | stringLength: {
19 | min: 8,
20 | max: 40,
21 | message: 'The full name must be more than %s and less than %s characters long'
22 | },
23 | regexp: {
24 | enabled: false,
25 | regexp: /^[a-zA-Z\s]+$/,
26 | message: 'The full name can only consist of alphabetical, number, and space'
27 | }
28 | }
29 | }
30 | }
31 | });
32 |
33 | this.bv = $('#enableForm').data('bootstrapValidator');
34 | this.$fullName = this.bv.getFieldElements('fullName');
35 | });
36 |
37 | afterEach(function() {
38 | $('#enableForm').bootstrapValidator('destroy').remove();
39 | });
40 |
41 | it('enable all validators', function() {
42 | this.$fullName.val('@ $full N@m3');
43 | this.bv.validate();
44 | expect(this.bv.isValid()).toBeTruthy();
45 |
46 | this.bv.resetForm();
47 | this.$fullName.val('Contain#$@');
48 | this.bv.enableFieldValidators('fullName', true);
49 | this.bv.validate();
50 | expect(this.bv.isValidField('fullName')).toEqual(false);
51 | expect(this.bv.isValid()).toEqual(false);
52 | });
53 |
54 | it('disable all validators', function() {
55 | this.bv.resetForm();
56 | this.bv.enableFieldValidators('fullName', false);
57 | this.bv.validate();
58 | expect(this.bv.isValid()).toBeTruthy();
59 | });
60 |
61 | it('enabled option particular validator', function() {
62 | this.$fullName.val('Contain@#$');
63 | this.bv.validate();
64 | expect(this.bv.isValid()).toBeTruthy();
65 |
66 | var messages = this.bv.getMessages('fullName');
67 | expect(messages.length).toEqual(0);
68 | });
69 |
70 | it('enable particular validators', function() {
71 | // Enable stringLength validator
72 | this.bv.resetForm();
73 | this.bv.enableFieldValidators('fullName', true, 'stringLength');
74 | this.bv.enableFieldValidators('fullName', true, 'regexp');
75 | this.$fullName.val('Full@');
76 | this.bv.validate();
77 | expect(this.bv.isValid()).toEqual(false);
78 |
79 | var messages = this.bv.getMessages('fullName');
80 | expect($.inArray('The full name must be more than 8 and less than 40 characters long', messages)).toBeGreaterThan(-1);
81 | expect($.inArray('The full name can only consist of alphabetical, number, and space', messages)).toBeGreaterThan(-1);
82 | });
83 |
84 | it('disable particular validators', function() {
85 | // Disable stringLength validator
86 | this.bv.enableFieldValidators('fullName', false, 'stringLength');
87 | this.$fullName.val('Full');
88 | this.bv.validate();
89 | expect(this.bv.isValid()).toBeTruthy();
90 |
91 | var messages = this.bv.getMessages('fullName');
92 | expect($.inArray('The full name must be more than 8 and less than 40 characters long', messages)).toEqual(-1);
93 |
94 | // Disable regexp validator
95 | this.bv.enableFieldValidators('fullName', false, 'regexp');
96 | this.$fullName.val('Special@#$');
97 | this.bv.validate();
98 | expect(this.bv.isValid()).toBeTruthy();
99 |
100 | var messages = this.bv.getMessages('fullName');
101 | expect($.inArray('The full name can only consist of alphabetical, number, and space', messages)).toEqual(-1);
102 | });
103 | });
104 |
--------------------------------------------------------------------------------
/test/spec/group.js:
--------------------------------------------------------------------------------
1 | describe('group option', function() {
2 | beforeEach(function() {
3 | $([
4 | ''
27 | ].join('')).appendTo('body');
28 |
29 | $('#groupForm').bootstrapValidator({
30 | fields: {
31 | firstName: {
32 | group: '.firstNameGroup',
33 | validators: {
34 | notEmpty: {
35 | message: 'The first name is required and cannot be empty'
36 | }
37 | }
38 | },
39 | lastName: {
40 | validators: {
41 | notEmpty: {
42 | message: 'The last name is required and cannot be empty'
43 | }
44 | }
45 | },
46 | username: {
47 | validators: {
48 | notEmpty: {
49 | message: 'The username is required and cannot be empty'
50 | },
51 | stringLength: {
52 | min: 6,
53 | max: 30,
54 | message: 'The username must be more than 6 and less than 30 characters long'
55 | },
56 | regexp: {
57 | regexp: /^[a-zA-Z0-9_\.]+$/,
58 | message: 'The username can only consist of alphabetical, number, dot and underscore'
59 | }
60 | }
61 | }
62 | }
63 | });
64 |
65 | this.bv = $('#groupForm').data('bootstrapValidator');
66 | this.$firstName = this.bv.getFieldElements('firstName');
67 | this.$lastName = this.bv.getFieldElements('lastName');
68 | this.$username = this.bv.getFieldElements('username');
69 | });
70 |
71 | afterEach(function() {
72 | $('#groupForm').bootstrapValidator('destroy').remove();
73 | });
74 |
75 | it('group default', function() {
76 | this.$username.val('123@#$');
77 | this.bv.validate();
78 | expect(this.$username.parents('.form-group').hasClass('has-error')).toBeTruthy();
79 | expect(this.$username.parents('.form-group').hasClass('has-success')).toEqual(false);
80 |
81 | this.bv.resetForm();
82 | this.$username.val('validUser.Name');
83 | this.bv.validate();
84 | expect(this.$username.parents('.form-group').hasClass('has-success')).toBeTruthy();
85 | expect(this.$username.parents('.form-group').hasClass('has-error')).toEqual(false);
86 | });
87 |
88 | it('group programmatically', function() {
89 | this.$firstName.val('');
90 | this.bv.validate();
91 | expect(this.$firstName.parents('.firstNameGroup').hasClass('has-error')).toBeTruthy();
92 | expect(this.$firstName.parents('.firstNameGroup').hasClass('has-success')).toEqual(false);
93 | expect(this.$firstName.parents('.form-group').hasClass('has-error')).toEqual(false);
94 | });
95 |
96 | it('group declarative', function() {
97 | this.$firstName.val('First');
98 | this.$lastName.val('Last');
99 | this.bv.validate();
100 | expect(this.$lastName.parents('.lastNameGroup').hasClass('has-success')).toBeTruthy();
101 | expect(this.$lastName.parents('.lastNameGroup').hasClass('has-error')).toEqual(false);
102 | expect(this.$lastName.parents('.form-group').hasClass('has-success')).toEqual(false);
103 | expect(this.$lastName.parents('.form-group').hasClass('has-error')).toEqual(false);
104 | });
105 | });
106 |
--------------------------------------------------------------------------------
/test/spec/message.js:
--------------------------------------------------------------------------------
1 | describe('message', function() {
2 | beforeEach(function() {
3 | var html = [
4 | ''
11 | ].join('\n');
12 |
13 | $(html).appendTo('body');
14 | $('#messageForm').bootstrapValidator({
15 | fields: {
16 | password: {
17 | validators: {
18 | notEmpty: {
19 | message: 'The password is required'
20 | },
21 | callback: {
22 | callback: function(value, validator) {
23 | // Check the password strength
24 | if (value.length < 6) {
25 | return {
26 | valid: false,
27 | message: 'The password must be more than 6 characters'
28 | }
29 | }
30 |
31 | if (value === value.toLowerCase()) {
32 | return {
33 | valid: false,
34 | message: 'The password must contain at least one upper case character'
35 | }
36 | }
37 | if (value === value.toUpperCase()) {
38 | return {
39 | valid: false,
40 | message: 'The password must contain at least one lower case character'
41 | }
42 | }
43 | if (value.search(/[0-9]/) < 0) {
44 | return {
45 | valid: false,
46 | message: 'The password must contain at least one digit'
47 | }
48 | }
49 |
50 | return true;
51 | }
52 | }
53 | }
54 | }
55 | }
56 | });
57 |
58 | this.bv = $('#messageForm').data('bootstrapValidator');
59 | this.$password = this.bv.getFieldElements('password');
60 | });
61 |
62 | afterEach(function() {
63 | $('#messageForm').bootstrapValidator('destroy').parent().remove();
64 | });
65 |
66 | it('update message from callback', function() {
67 | this.bv.resetForm();
68 | this.$password.val('123');
69 | this.bv.validate();
70 | expect(this.bv.getMessages('password', 'callback')[0]).toEqual('The password must be more than 6 characters');
71 |
72 | this.bv.resetForm();
73 | this.$password.val('no_upper_case!@#');
74 | this.bv.validate();
75 | expect(this.bv.getMessages('password', 'callback')[0]).toEqual('The password must contain at least one upper case character');
76 |
77 | this.bv.resetForm();
78 | this.$password.val('NO_LOWER_CASE123');
79 | this.bv.validate();
80 | expect(this.bv.getMessages('password', 'callback')[0]).toEqual('The password must contain at least one lower case character');
81 |
82 | this.bv.resetForm();
83 | this.$password.val('NoDigits!@#');
84 | this.bv.validate();
85 | expect(this.bv.getMessages('password', 'callback')[0]).toEqual('The password must contain at least one digit');
86 | });
87 |
88 | it('call updateMessage()', function() {
89 | this.bv.updateStatus('password', this.bv.STATUS_INVALID, 'callback');
90 |
91 | this.bv.updateMessage('password', 'callback', 'The password is weak');
92 | expect(this.bv.getMessages('password', 'callback')[0]).toEqual('The password is weak');
93 |
94 | this.bv.updateMessage(this.$password, 'callback', 'The password is not strong');
95 | expect(this.bv.getMessages(this.$password, 'callback')[0]).toEqual('The password is not strong');
96 | });
97 | });
98 |
--------------------------------------------------------------------------------
/test/spec/validator/callback.js:
--------------------------------------------------------------------------------
1 | function validateCaptcha(value, validator, $field) {
2 | var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]);
3 | return value === sum + '';
4 | };
5 |
6 | describe('callback', function() {
7 | beforeEach(function() {
8 | $([
9 | ''
22 | ].join('\n')).appendTo('body');
23 |
24 | $('#callbackForm').bootstrapValidator({
25 | fields: {
26 | captcha: {
27 | validators: {
28 | callback: {
29 | message: 'Wrong answer',
30 | callback: function(value, validator, $field) {
31 | return validateCaptcha(value, validator, $field);
32 | }
33 | }
34 | }
35 | }
36 | }
37 | });
38 |
39 | this.bv = $('#callbackForm').data('bootstrapValidator');
40 | this.$captcha = this.bv.getFieldElements('captcha');
41 | this.$declarativeCaptcha = this.bv.getFieldElements('declarativeCaptcha');
42 | });
43 |
44 | afterEach(function() {
45 | $('#callbackForm').bootstrapValidator('destroy').remove();
46 | });
47 |
48 | it('execute the callback', function() {
49 | $('#captchaOperation').html('1 + 2');
50 |
51 | this.$captcha.val('3');
52 | this.bv.validate();
53 | expect(this.bv.isValidField('captcha')).toBeTruthy();
54 |
55 | this.bv.resetForm();
56 | this.$captcha.val('5');
57 | this.bv.validate();
58 | expect(this.bv.isValidField('captcha')).toEqual(false);
59 | });
60 |
61 | it('callback declarative', function() {
62 | $('#captchaOperation').html('10 + 20');
63 |
64 | this.$declarativeCaptcha.val('40');
65 | this.bv.validate();
66 | expect(this.bv.isValidField('declarativeCaptcha')).toEqual(false);
67 |
68 | this.bv.resetForm();
69 | this.$declarativeCaptcha.val('30');
70 | this.bv.validate();
71 | expect(this.bv.isValidField('declarativeCaptcha')).toBeTruthy();
72 | });
73 | });
74 |
--------------------------------------------------------------------------------
/test/spec/validator/creditCard.js:
--------------------------------------------------------------------------------
1 | describe('creditCard', function() {
2 | // Get the fake credit card number at http://www.getcreditcardnumbers.com/
3 |
4 | beforeEach(function() {
5 | var html = [
6 | ''
13 | ].join('\n');
14 |
15 | $(html).appendTo('body');
16 | $('#ccForm').bootstrapValidator();
17 |
18 | this.bv = $('#ccForm').data('bootstrapValidator');
19 | this.$creditCard = this.bv.getFieldElements('cc');
20 | });
21 |
22 | afterEach(function() {
23 | $('#ccForm').bootstrapValidator('destroy').parent().remove();
24 | });
25 |
26 | it('accept spaces', function() {
27 | this.$creditCard.val('5267 9789 9451 9654');
28 | this.bv.validate();
29 | expect(this.bv.isValidField('cc')).toBeTruthy();
30 | });
31 |
32 | it('accept dashes', function() {
33 | this.$creditCard.val('6011-2649-6840-4521');
34 | this.bv.validate();
35 | expect(this.bv.isValidField('cc')).toBeTruthy();
36 | });
37 |
38 | it('invalid format', function() {
39 | this.$creditCard.val('4539.1870.2954.3862');
40 | this.bv.validate();
41 | expect(this.bv.isValidField('cc')).toEqual(false);
42 | });
43 |
44 | it('American Express', function() {
45 | this.$creditCard.val('340653705597107');
46 | this.bv.validate();
47 | expect(this.bv.isValidField('cc')).toBeTruthy();
48 | });
49 |
50 | it('American Express invalid length', function() {
51 | this.$creditCard.val('3744148309166730');
52 | this.bv.validate();
53 | expect(this.bv.isValidField('cc')).toEqual(false);
54 | });
55 |
56 | it('American Express invalid prefix', function() {
57 | this.$creditCard.val('356120148436654');
58 | this.bv.validate();
59 | expect(this.bv.isValidField('cc')).toEqual(false);
60 | });
61 |
62 | it('Diners Club', function() {
63 | this.$creditCard.val('30130708434187');
64 | this.bv.validate();
65 | expect(this.bv.isValidField('cc')).toBeTruthy();
66 | });
67 |
68 | it('Diners Club (US)', function() {
69 | this.$creditCard.val('5517479515603901');
70 | this.bv.validate();
71 | expect(this.bv.isValidField('cc')).toBeTruthy();
72 | });
73 |
74 | it('Discover', function() {
75 | this.$creditCard.val('6011734674929094');
76 | this.bv.validate();
77 | expect(this.bv.isValidField('cc')).toBeTruthy();
78 | });
79 |
80 | it('JCB', function() {
81 | this.$creditCard.val('3566002020360505');
82 | this.bv.validate();
83 | expect(this.bv.isValidField('cc')).toBeTruthy();
84 | });
85 |
86 | it('Laser', function() {
87 | this.$creditCard.val('6304 9000 1774 0292 441');
88 | this.bv.validate();
89 | expect(this.bv.isValidField('cc')).toBeTruthy();
90 | });
91 |
92 | it('Maestro', function() {
93 | this.$creditCard.val('6762835098779303');
94 | this.bv.validate();
95 | expect(this.bv.isValidField('cc')).toBeTruthy();
96 | });
97 |
98 | it('Mastercard', function() {
99 | this.$creditCard.val('5303765013600904');
100 | this.bv.validate();
101 | expect(this.bv.isValidField('cc')).toBeTruthy();
102 | });
103 |
104 | it('Solo', function() {
105 | this.$creditCard.val('6334580500000000');
106 | this.bv.validate();
107 | expect(this.bv.isValidField('cc')).toBeTruthy();
108 | });
109 |
110 | it('Visa', function() {
111 | this.$creditCard.val('4929248980295542');
112 | this.bv.validate();
113 | expect(this.bv.isValidField('cc')).toBeTruthy();
114 | });
115 |
116 | it('Visa invalid check digit', function() {
117 | this.$creditCard.val('4532599916257826');
118 | this.bv.validate();
119 | expect(this.bv.isValidField('cc')).toEqual(false);
120 | });
121 | });
122 |
--------------------------------------------------------------------------------
/test/spec/validator/ean.js:
--------------------------------------------------------------------------------
1 | describe('ean', function() {
2 | beforeEach(function() {
3 | var html = [
4 | ''
11 | ].join('\n');
12 |
13 | $(html).appendTo('body');
14 | $('#eanForm').bootstrapValidator();
15 |
16 | this.bv = $('#eanForm').data('bootstrapValidator');
17 | this.$ean = this.bv.getFieldElements('ean');
18 | });
19 |
20 | afterEach(function() {
21 | $('#eanForm').bootstrapValidator('destroy').parent().remove();
22 | });
23 |
24 | it('valid', function() {
25 | var samples = ['73513537', '9780471117094', '4006381333931'];
26 |
27 | for (var i in samples) {
28 | this.$ean.val(samples[i]);
29 | this.bv.validate();
30 | expect(this.bv.isValidField('ean')).toBeTruthy();
31 | }
32 | });
33 |
34 | it('contains only digits', function() {
35 | this.$ean.val('123abcDEF!@#');
36 | this.bv.validate();
37 | expect(this.bv.isValidField('ean')).toEqual(false);
38 | });
39 |
40 | it('invalid length', function() {
41 | this.$ean.val('1234567');
42 | this.bv.validate();
43 | expect(this.bv.isValidField('ean')).toEqual(false);
44 | });
45 |
46 | it('invalid check digit', function() {
47 | this.$ean.val('73513536');
48 | this.bv.validate();
49 | expect(this.bv.isValidField('ean')).toEqual(false);
50 | });
51 | });
52 |
--------------------------------------------------------------------------------
/test/spec/validator/imo.js:
--------------------------------------------------------------------------------
1 | describe('imo', function() {
2 | beforeEach(function() {
3 | $([
4 | ''
9 | ].join('\n')).appendTo('body');
10 |
11 | $('#imoForm').bootstrapValidator();
12 |
13 | this.bv = $('#imoForm').data('bootstrapValidator');
14 | this.$imo = this.bv.getFieldElements('imo');
15 | });
16 |
17 | afterEach(function() {
18 | $('#imoForm').bootstrapValidator('destroy').remove();
19 | });
20 |
21 | it('Valid IMO (upper)', function() {
22 | this.bv.resetForm();
23 | this.$imo.val('IMO 9074729');
24 | this.bv.validate();
25 | expect(this.bv.isValid()).toBeTruthy();
26 | });
27 |
28 | it('Valid IMO (lower)', function() {
29 | this.bv.resetForm();
30 | this.$imo.val('imo 9074729');
31 | this.bv.validate();
32 | expect(this.bv.isValid()).toBeTruthy();
33 | });
34 |
35 | it('Invalid IMO (bad format)', function() {
36 | this.bv.resetForm();
37 | this.$imo.val('9074729');
38 | this.bv.validate();
39 | expect(this.bv.isValid()).toBeFalsy();
40 | });
41 |
42 | it('Invalid IMO (bad check digit)', function() {
43 | this.bv.resetForm();
44 | this.$imo.val('IMO 9074728');
45 | this.bv.validate();
46 | expect(this.bv.isValid()).toBeFalsy();
47 | });
48 | });
49 |
--------------------------------------------------------------------------------
/test/spec/validator/isbn.js:
--------------------------------------------------------------------------------
1 | describe('isbn', function() {
2 | beforeEach(function() {
3 | var html = [
4 | ''
11 | ].join('\n');
12 |
13 | $(html).appendTo('body');
14 | $('#isbnForm').bootstrapValidator();
15 |
16 | this.bv = $('#isbnForm').data('bootstrapValidator');
17 | this.$isbn = this.bv.getFieldElements('isbn');
18 | });
19 |
20 | afterEach(function() {
21 | $('#isbnForm').bootstrapValidator('destroy').parent().remove();
22 | });
23 |
24 | it('isbn10 hyphen', function() {
25 | var samples = ['99921-58-10-7', '9971-5-0210-0', '960-425-059-0', '80-902734-1-6'];
26 |
27 | for (var i in samples) {
28 | this.$isbn.val(samples[i]);
29 | this.bv.validate();
30 | expect(this.bv.isValidField('isbn')).toBeTruthy();
31 | }
32 | });
33 |
34 | it('isbn10 space', function() {
35 | var samples = ['85 359 0277 5', '1 84356 028 3', '0 684 84328 5', '0 85131 041 9', '0 943396 04 2'];
36 |
37 | for (var i in samples) {
38 | this.$isbn.val(samples[i]);
39 | this.bv.validate();
40 | expect(this.bv.isValidField('isbn')).toBeTruthy();
41 | }
42 | });
43 |
44 | it('isbn10 hyphen with X', function() {
45 | var samples = ['0-8044-2957-X', '0-9752298-0-X'];
46 | for (var i in samples) {
47 | this.$isbn.val(samples[i]);
48 | this.bv.validate();
49 | expect(this.bv.isValidField('isbn')).toBeTruthy();
50 | }
51 | });
52 |
53 | it('isbn10 invalid check digit', function() {
54 | this.$isbn.val('99921-58-10-6');
55 | this.bv.validate();
56 | expect(this.bv.isValidField('isbn')).toEqual(false);
57 | });
58 |
59 | it('isbn13', function() {
60 | this.$isbn.val('978-0-306-40615-7');
61 | this.bv.validate();
62 | expect(this.bv.isValidField('isbn')).toBeTruthy();
63 | });
64 |
65 | it('isbn13 invalid check digit', function() {
66 | this.$isbn.val('978-0-306-40615-6');
67 | this.bv.validate();
68 | expect(this.bv.isValidField('isbn')).toEqual(false);
69 | });
70 | });
71 |
--------------------------------------------------------------------------------
/test/spec/validator/isin.js:
--------------------------------------------------------------------------------
1 | describe('isin', function() {
2 | beforeEach(function() {
3 | var html = [
4 | ''
11 | ].join('\n');
12 |
13 | $(html).appendTo('body');
14 | $('#isinForm').bootstrapValidator();
15 |
16 | this.bv = $('#isinForm').data('bootstrapValidator');
17 | this.$isin = this.bv.getFieldElements('isin');
18 | });
19 |
20 | afterEach(function() {
21 | $('#isinForm').bootstrapValidator('destroy').parent().remove();
22 | });
23 |
24 | it('valid', function() {
25 | var samples = ['US0378331005', 'AU0000XVGZA3', 'GB0002634946'];
26 |
27 | for (var i in samples) {
28 | this.$isin.val(samples[i]);
29 | this.bv.validate();
30 | expect(this.bv.isValidField('isin')).toBeTruthy();
31 | }
32 | });
33 |
34 | it('invalid country code', function() {
35 | this.$isin.val('AA0000XVGZA3');
36 | this.bv.validate();
37 | expect(this.bv.isValidField('isin')).toEqual(false);
38 | });
39 |
40 | it('contains only digits and alphabet', function() {
41 | this.$isin.val('US12345ABC@#$');
42 | this.bv.validate();
43 | expect(this.bv.isValidField('isin')).toEqual(false);
44 | });
45 |
46 | it('invalid length', function() {
47 | this.$isin.val('US1234567');
48 | this.bv.validate();
49 | expect(this.bv.isValidField('isin')).toEqual(false);
50 | });
51 |
52 | it('invalid check digit', function() {
53 | this.$isin.val('US0378331004');
54 | this.bv.validate();
55 | expect(this.bv.isValidField('isin')).toEqual(false);
56 | });
57 | });
58 |
--------------------------------------------------------------------------------
/test/spec/validator/ismn.js:
--------------------------------------------------------------------------------
1 | describe('ismn', function() {
2 | beforeEach(function() {
3 | var html = [
4 | ''
11 | ].join('\n');
12 |
13 | $(html).appendTo('body');
14 | $('#ismnForm').bootstrapValidator();
15 |
16 | this.bv = $('#ismnForm').data('bootstrapValidator');
17 | this.$ismn = this.bv.getFieldElements('ismn');
18 | });
19 |
20 | afterEach(function() {
21 | $('#ismnForm').bootstrapValidator('destroy').parent().remove();
22 | });
23 |
24 | it('valid start with M', function() {
25 | this.$ismn.val('M230671187');
26 | this.bv.validate();
27 | expect(this.bv.isValidField('ismn')).toBeTruthy();
28 | });
29 |
30 | it('valid start with 979', function() {
31 | this.$ismn.val('9790060115615');
32 | this.bv.validate();
33 | expect(this.bv.isValidField('ismn')).toBeTruthy();
34 | });
35 |
36 | it('valid contains spaces', function() {
37 | this.$ismn.val('979 0 3452 4680 5');
38 | this.bv.validate();
39 | expect(this.bv.isValidField('ismn')).toBeTruthy();
40 | });
41 |
42 | it('valid contains dashes', function() {
43 | this.$ismn.val('979-0-0601-1561-5');
44 | this.bv.validate();
45 | expect(this.bv.isValidField('ismn')).toBeTruthy();
46 | });
47 |
48 | it('invalid format', function() {
49 | this.$ismn.val('N123456789');
50 | this.bv.validate();
51 | expect(this.bv.isValidField('ismn')).toEqual(false);
52 | });
53 |
54 | it('invalid check digit', function() {
55 | this.$ismn.val('9790060115614');
56 | this.bv.validate();
57 | expect(this.bv.isValidField('ismn')).toEqual(false);
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/test/spec/validator/issn.js:
--------------------------------------------------------------------------------
1 | describe('issn', function() {
2 | beforeEach(function() {
3 | var html = [
4 | ''
11 | ].join('\n');
12 |
13 | $(html).appendTo('body');
14 | $('#issnForm').bootstrapValidator();
15 |
16 | this.bv = $('#issnForm').data('bootstrapValidator');
17 | this.$issn = this.bv.getFieldElements('issn');
18 | });
19 |
20 | afterEach(function() {
21 | $('#issnForm').bootstrapValidator('destroy').parent().remove();
22 | });
23 |
24 | it('valid', function() {
25 | var samples = ['0378-5955', '0024-9319', '0032-1478'];
26 |
27 | for (var i in samples) {
28 | this.$issn.val(samples[i]);
29 | this.bv.validate();
30 | expect(this.bv.isValidField('issn')).toBeTruthy();
31 | }
32 | });
33 |
34 | it('not contains hyphen', function() {
35 | this.$issn.val('03785955');
36 | this.bv.validate();
37 | expect(this.bv.isValidField('issn')).toEqual(false);
38 | });
39 |
40 | it('contains only digits, X', function() {
41 | this.$issn.val('1234-566A');
42 | this.bv.validate();
43 | expect(this.bv.isValidField('issn')).toEqual(false);
44 | });
45 |
46 | it('invalid check sum', function() {
47 | this.$issn.val('0032-147X');
48 | this.bv.validate();
49 | expect(this.bv.isValidField('issn')).toEqual(false);
50 | });
51 | });
52 |
--------------------------------------------------------------------------------
/test/spec/validator/meid.js:
--------------------------------------------------------------------------------
1 | describe('meid', function() {
2 | beforeEach(function() {
3 | $([
4 | ''
9 | ].join('\n')).appendTo('body');
10 |
11 | $('#meidForm').bootstrapValidator();
12 |
13 | this.bv = $('#meidForm').data('bootstrapValidator');
14 | this.$meid = this.bv.getFieldElements('meid');
15 | });
16 |
17 | afterEach(function() {
18 | $('#meidForm').bootstrapValidator('destroy').remove();
19 | });
20 |
21 | it('Valid MEID (14 hex, check digit)', function() {
22 | this.bv.resetForm();
23 | this.$meid.val('A00000049259B16');
24 | this.bv.validate();
25 | expect(this.bv.isValid()).toBeTruthy();
26 | });
27 |
28 | it('Valid MEID (14 hex, dashes, check digit)', function() {
29 | this.bv.resetForm();
30 | this.$meid.val('A0-000004-9259B1-6');
31 | this.bv.validate();
32 | expect(this.bv.isValid()).toBeTruthy();
33 | });
34 |
35 | it('Valid MEID (14 hex, spaces, check digit)', function() {
36 | this.bv.resetForm();
37 | this.$meid.val('A0 000004 9259B1 6');
38 | this.bv.validate();
39 | expect(this.bv.isValid()).toBeTruthy();
40 | });
41 |
42 | it('Valid MEID (18 dec, check digit)', function() {
43 | this.bv.resetForm();
44 | this.$meid.val('2936087365007037100');
45 | this.bv.validate();
46 | expect(this.bv.isValid()).toBeTruthy();
47 | });
48 |
49 | it('Valid MEID (18 dec, dashes, check digit)', function() {
50 | this.bv.resetForm();
51 | this.$meid.val('29360-87365-0070-3710-0');
52 | this.bv.validate();
53 | expect(this.bv.isValid()).toBeTruthy();
54 | });
55 |
56 | it('Valid MEID (18 dec, spaces, check digit)', function() {
57 | this.bv.resetForm();
58 | this.$meid.val('29360 87365 0070 3710 0');
59 | this.bv.validate();
60 | expect(this.bv.isValid()).toBeTruthy();
61 | });
62 |
63 | it('Valid MEID (14 hex)', function() {
64 | this.bv.resetForm();
65 | this.$meid.val('AF0123450ABCDE');
66 | this.bv.validate();
67 | expect(this.bv.isValid()).toBeTruthy();
68 | });
69 |
70 | it('Valid MEID (14 hex, dashes)', function() {
71 | this.bv.resetForm();
72 | this.$meid.val('AF-012345-0ABCDE');
73 | this.bv.validate();
74 | expect(this.bv.isValid()).toBeTruthy();
75 | });
76 |
77 | it('Valid MEID (14 hex, spaces)', function() {
78 | this.bv.resetForm();
79 | this.$meid.val('AF 012345 0ABCDE');
80 | this.bv.validate();
81 | expect(this.bv.isValid()).toBeTruthy();
82 | });
83 |
84 | it('Valid MEID (18 dec)', function() {
85 | this.bv.resetForm();
86 | this.$meid.val('293608736500703710');
87 | this.bv.validate();
88 | expect(this.bv.isValid()).toBeTruthy();
89 | });
90 |
91 | it('Valid MEID (18 dec, dashes)', function() {
92 | this.bv.resetForm();
93 | this.$meid.val('29360-87365-0070-3710');
94 | this.bv.validate();
95 | expect(this.bv.isValid()).toBeTruthy();
96 | });
97 |
98 | it('Valid MEID (18 dec, spaces)', function() {
99 | this.bv.resetForm();
100 | this.$meid.val('29360 87365 0070 3710');
101 | this.bv.validate();
102 | expect(this.bv.isValid()).toBeTruthy();
103 | });
104 |
105 | it('Invalid MEID (14 hex, bad check digit)', function() {
106 | this.bv.resetForm();
107 | this.$meid.val('A00000049259B15');
108 | this.bv.validate();
109 | expect(this.bv.isValid()).toBeFalsy();
110 | });
111 |
112 | it('Invalid MEID (13 hex)', function() {
113 | this.bv.resetForm();
114 | this.$meid.val('A00000049259B');
115 | this.bv.validate();
116 | expect(this.bv.isValid()).toBeFalsy();
117 | });
118 |
119 | it('Invalid MEID (18 dec, bad check digit)', function() {
120 | this.bv.resetForm();
121 | this.$meid.val('2936087365007037101');
122 | this.bv.validate();
123 | expect(this.bv.isValid()).toBeFalsy();
124 | });
125 |
126 | it('Invalid MEID (17 dec)', function() {
127 | this.bv.resetForm();
128 | this.$meid.val('29360873650070371');
129 | this.bv.validate();
130 | expect(this.bv.isValid()).toBeFalsy();
131 | });
132 | });
133 |
--------------------------------------------------------------------------------
/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nghuuphuoc/bootstrapvalidator/0c96659eda586269c02a45948744ac135676ff0d/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nghuuphuoc/bootstrapvalidator/0c96659eda586269c02a45948744ac135676ff0d/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nghuuphuoc/bootstrapvalidator/0c96659eda586269c02a45948744ac135676ff0d/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/vendor/bootstrap/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/vendor/jasmine/console.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2013 Pivotal Labs
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 | function getJasmineRequireObj() {
24 | if (typeof module !== "undefined" && module.exports) {
25 | return exports;
26 | } else {
27 | window.jasmineRequire = window.jasmineRequire || {};
28 | return window.jasmineRequire;
29 | }
30 | }
31 |
32 | getJasmineRequireObj().console = function(jRequire, j$) {
33 | j$.ConsoleReporter = jRequire.ConsoleReporter();
34 | };
35 |
36 | getJasmineRequireObj().ConsoleReporter = function() {
37 |
38 | var noopTimer = {
39 | start: function(){},
40 | elapsed: function(){ return 0; }
41 | };
42 |
43 | function ConsoleReporter(options) {
44 | var print = options.print,
45 | showColors = options.showColors || false,
46 | onComplete = options.onComplete || function() {},
47 | timer = options.timer || noopTimer,
48 | specCount,
49 | failureCount,
50 | failedSpecs = [],
51 | pendingCount,
52 | ansi = {
53 | green: '\x1B[32m',
54 | red: '\x1B[31m',
55 | yellow: '\x1B[33m',
56 | none: '\x1B[0m'
57 | };
58 |
59 | this.jasmineStarted = function() {
60 | specCount = 0;
61 | failureCount = 0;
62 | pendingCount = 0;
63 | print("Started");
64 | printNewline();
65 | timer.start();
66 | };
67 |
68 | this.jasmineDone = function() {
69 | printNewline();
70 | for (var i = 0; i < failedSpecs.length; i++) {
71 | specFailureDetails(failedSpecs[i]);
72 | }
73 |
74 | printNewline();
75 | var specCounts = specCount + " " + plural("spec", specCount) + ", " +
76 | failureCount + " " + plural("failure", failureCount);
77 |
78 | if (pendingCount) {
79 | specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount);
80 | }
81 |
82 | print(specCounts);
83 |
84 | printNewline();
85 | var seconds = timer.elapsed() / 1000;
86 | print("Finished in " + seconds + " " + plural("second", seconds));
87 |
88 | printNewline();
89 |
90 | onComplete(failureCount === 0);
91 | };
92 |
93 | this.specDone = function(result) {
94 | specCount++;
95 |
96 | if (result.status == "pending") {
97 | pendingCount++;
98 | print(colored("yellow", "*"));
99 | return;
100 | }
101 |
102 | if (result.status == "passed") {
103 | print(colored("green", '.'));
104 | return;
105 | }
106 |
107 | if (result.status == "failed") {
108 | failureCount++;
109 | failedSpecs.push(result);
110 | print(colored("red", 'F'));
111 | }
112 | };
113 |
114 | return this;
115 |
116 | function printNewline() {
117 | print("\n");
118 | }
119 |
120 | function colored(color, str) {
121 | return showColors ? (ansi[color] + str + ansi.none) : str;
122 | }
123 |
124 | function plural(str, count) {
125 | return count == 1 ? str : str + "s";
126 | }
127 |
128 | function repeat(thing, times) {
129 | var arr = [];
130 | for (var i = 0; i < times; i++) {
131 | arr.push(thing);
132 | }
133 | return arr;
134 | }
135 |
136 | function indent(str, spaces) {
137 | var lines = (str || '').split("\n");
138 | var newArr = [];
139 | for (var i = 0; i < lines.length; i++) {
140 | newArr.push(repeat(" ", spaces).join("") + lines[i]);
141 | }
142 | return newArr.join("\n");
143 | }
144 |
145 | function specFailureDetails(result) {
146 | printNewline();
147 | print(result.fullName);
148 |
149 | for (var i = 0; i < result.failedExpectations.length; i++) {
150 | var failedExpectation = result.failedExpectations[i];
151 | printNewline();
152 | print(indent(failedExpectation.stack, 2));
153 | }
154 |
155 | printNewline();
156 | }
157 | }
158 |
159 | return ConsoleReporter;
160 | };
161 |
--------------------------------------------------------------------------------
/vendor/jasmine/jasmine.css:
--------------------------------------------------------------------------------
1 | body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
2 |
3 | .html-reporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
4 | .html-reporter a { text-decoration: none; }
5 | .html-reporter a:hover { text-decoration: underline; }
6 | .html-reporter p, .html-reporter h1, .html-reporter h2, .html-reporter h3, .html-reporter h4, .html-reporter h5, .html-reporter h6 { margin: 0; line-height: 14px; }
7 | .html-reporter .banner, .html-reporter .symbol-summary, .html-reporter .summary, .html-reporter .result-message, .html-reporter .spec .description, .html-reporter .spec-detail .description, .html-reporter .alert .bar, .html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
8 | .html-reporter .banner .version { margin-left: 14px; }
9 | .html-reporter #jasmine_content { position: fixed; right: 100%; }
10 | .html-reporter .version { color: #aaaaaa; }
11 | .html-reporter .banner { margin-top: 14px; }
12 | .html-reporter .duration { color: #aaaaaa; float: right; }
13 | .html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
14 | .html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; }
15 | .html-reporter .symbol-summary li.passed { font-size: 14px; }
16 | .html-reporter .symbol-summary li.passed:before { color: #5e7d00; content: "\02022"; }
17 | .html-reporter .symbol-summary li.failed { line-height: 9px; }
18 | .html-reporter .symbol-summary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
19 | .html-reporter .symbol-summary li.disabled { font-size: 14px; }
20 | .html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
21 | .html-reporter .symbol-summary li.pending { line-height: 17px; }
22 | .html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
23 | .html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
24 | .html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
25 | .html-reporter .bar.failed { background-color: #b03911; }
26 | .html-reporter .bar.passed { background-color: #a6b779; }
27 | .html-reporter .bar.skipped { background-color: #bababa; }
28 | .html-reporter .bar.menu { background-color: #fff; color: #aaaaaa; }
29 | .html-reporter .bar.menu a { color: #333333; }
30 | .html-reporter .bar a { color: white; }
31 | .html-reporter.spec-list .bar.menu.failure-list, .html-reporter.spec-list .results .failures { display: none; }
32 | .html-reporter.failure-list .bar.menu.spec-list, .html-reporter.failure-list .summary { display: none; }
33 | .html-reporter .running-alert { background-color: #666666; }
34 | .html-reporter .results { margin-top: 14px; }
35 | .html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
36 | .html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
37 | .html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
38 | .html-reporter.showDetails .summary { display: none; }
39 | .html-reporter.showDetails #details { display: block; }
40 | .html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
41 | .html-reporter .summary { margin-top: 14px; }
42 | .html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
43 | .html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
44 | .html-reporter .summary li.passed a { color: #5e7d00; }
45 | .html-reporter .summary li.failed a { color: #b03911; }
46 | .html-reporter .summary li.pending a { color: #ba9d37; }
47 | .html-reporter .description + .suite { margin-top: 0; }
48 | .html-reporter .suite { margin-top: 14px; }
49 | .html-reporter .suite a { color: #333333; }
50 | .html-reporter .failures .spec-detail { margin-bottom: 28px; }
51 | .html-reporter .failures .spec-detail .description { background-color: #b03911; }
52 | .html-reporter .failures .spec-detail .description a { color: white; }
53 | .html-reporter .result-message { padding-top: 14px; color: #333333; white-space: pre; }
54 | .html-reporter .result-message span.result { display: block; }
55 | .html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
56 |
--------------------------------------------------------------------------------
/vendor/jasmine/jasmine_favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nghuuphuoc/bootstrapvalidator/0c96659eda586269c02a45948744ac135676ff0d/vendor/jasmine/jasmine_favicon.png
--------------------------------------------------------------------------------