Skip to content

Commit

Permalink
#168: Cleanup, update the Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
nghuuphuoc committed Apr 13, 2014
1 parent 6fa0527 commit e934af3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v0.4.2 (not released yet)

* [#168](https://github.com/nghuuphuoc/bootstrapvalidator/pull/168): Add siren and siret validators, thanks to [@jswale](https://github.com/jswale)

## v0.4.1 (2014-04-12)

* [#144](https://github.com/nghuuphuoc/bootstrapvalidator/issues/144), [#158](https://github.com/nghuuphuoc/bootstrapvalidator/issues/158): Fixed an issue that the custom submit handler is not fired from the second time
Expand Down
2 changes: 1 addition & 1 deletion bootstrapValidator.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrapValidator",
"version": "0.4.1",
"version": "0.4.2-dev",
"title": "BootstrapValidator",
"author": {
"name": "Nguyen Huu Phuoc",
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bootstrapValidator",
"description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
"version": "0.4.1",
"version": "0.4.2-dev",
"main": [
"dist/css/bootstrapValidator.css",
"dist/js/bootstrapValidator.js"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrapValidator",
"version": "0.4.1",
"version": "0.4.2-dev",
"description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
"keywords": ["jQuery", "plugin", "validate", "validator", "form", "Bootstrap"],
"author": {
Expand Down
31 changes: 13 additions & 18 deletions src/js/validator/siren.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
;(function($) {
(function($) {
$.fn.bootstrapValidator.validators.siret = {
html5Attributes : {
'message' : 'message'
},

/**
* Check if a string is a siren
* Check if a string is a siren number
*
* @param {BootstrapValidator}
* validator The validator plugin instance
* @param {jQuery}
* $field Field element
* @param {Object}
* options Consist of key: - message: The invalid message
* @param {BootstrapValidator} validator The validator plugin instance
* @param {jQuery} $field Field element
* @param {Object} options Consist of key:
* - message: The invalid message
* @returns {Boolean}
*/
validate : function(validator, $field, options) {
Expand All @@ -21,16 +15,17 @@
return true;
}

var sum = 0;
var tmp;
for (var cpt = 0; cpt < value.length; cpt++) {
if ((cpt % 2) == 1) {
tmp = value.charAt(cpt) * 2;
var sum = 0,
length = value.length,
tmp;
for (var i = 0; i < length; i++) {
if ((i % 2) == 1) {
tmp = value.charAt(i) * 2;
if (tmp > 9) {
tmp -= 9;
}
} else {
tmp = value.charAt(cpt);
tmp = value.charAt(i);
}
sum += parseInt(tmp);
}
Expand Down
39 changes: 17 additions & 22 deletions src/js/validator/siret.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
;(function($) {
(function($) {
$.fn.bootstrapValidator.validators.siret = {
html5Attributes : {
'message' : 'message'
},

/**
* Check if a string is a siret
*
* @param {BootstrapValidator}
* validator The validator plugin instance
* @param {jQuery}
* $field Field element
* @param {Object}
* options Consist of key: - message: The invalid message
* @returns {Boolean}
*/
/**
* Check if a string is a siret number
*
* @param {BootstrapValidator} validator The validator plugin instance
* @param {jQuery} $field Field element
* @param {Object} options Consist of key:
* - message: The invalid message
* @returns {Boolean}
*/
validate : function(validator, $field, options) {
var value = $field.val();
if (value == '') {
return true;
}

var sum = 0;
var tmp;
for (var cpt = 0; cpt < value.length; cpt++) {
if ((cpt % 2) == 0) {
tmp = value.charAt(cpt) * 2;
var sum = 0,
length = value.length,
tmp;
for (var i = 0; i < length; i++) {
if ((i % 2) == 0) {
tmp = value.charAt(i) * 2;
if (tmp > 9) {
tmp -= 9;
}
} else {
tmp = value.charAt(cpt);
tmp = value.charAt(i);
}
sum += parseInt(tmp);
}
Expand Down

0 comments on commit e934af3

Please sign in to comment.