Browse Source

VIN mask fix #1199

Robin Herbots 9 years ago
parent
commit
fc73180bae
3 changed files with 36 additions and 14 deletions
  1. 4 0
      CHANGELOG.md
  2. 12 13
      README_other.md
  3. 20 1
      js/inputmask.extensions.js

+ 4 - 0
CHANGELOG.md

@@ -2,6 +2,10 @@
 All notable changes to this project will be documented in this file.
 All notable changes to this project will be documented in this file.
 
 
 ## UNRELEASED
 ## UNRELEASED
+
+### Added
+- VIN mask #1199
+
 ### Updates
 ### Updates
 - improve getmetadata
 - improve getmetadata
 - patchValueProperty - enable native value property patch on IE10/IE11
 - patchValueProperty - enable native value property patch on IE10/IE11

+ 12 - 13
README_other.md

@@ -2,43 +2,42 @@
 ## Definitions
 ## Definitions
 - A   :     alphabetical uppercasing
 - A   :     alphabetical uppercasing
 - &   :     alfanumeric uppercasing
 - &   :     alfanumeric uppercasing
-- \#  :     hexadecimal
+- #  :     hexadecimal
 
 
 ## Aliases
 ## Aliases
 ### URL
 ### URL
 An URL mask for entering valid FTP, HTTP or HTTPS addresses.
 An URL mask for entering valid FTP, HTTP or HTTPS addresses.
 
 
 ```javascript
 ```javascript
-$(document).ready(function(){
-  $(selector).inputmask("url");
-});
+Inputmask("url").mask(selector);
 ```
 ```
 
 
 ### IP address
 ### IP address
 An IP address alias for entering valid IP addresses.
 An IP address alias for entering valid IP addresses.
 
 
 ```javascript
 ```javascript
-$(document).ready(function(){
-  $(selector).inputmask("ip");
-});
+Inputmask("ip").mask(selector);
 ```
 ```
 
 
 ### Email
 ### Email
 An email mask for entering valid email addresses.
 An email mask for entering valid email addresses.
 
 
 ```javascript
 ```javascript
-$(document).ready(function(){
-  $(selector).inputmask("email");
-});
+Inputmask("email").mask(selector);
 ```
 ```
 
 
 ### MAC
 ### MAC
 An MAC mask for entering valid MAC addresses.
 An MAC mask for entering valid MAC addresses.
 
 
 ```javascript
 ```javascript
-$(document).ready(function(){
-  $(selector).inputmask("mac");
-});
+Inputmask("mac").mask(selector);
+```
+
+### VIN (Vehicle identification number)
+An VIN mask for entering valid VIN codes.
+
+```javascript
+  Inputmask("vin").mask(selector);
 ```
 ```
 
 
 You can find/modify/extend these aliases in the inputmask.extensions.js
 You can find/modify/extend these aliases in the inputmask.extensions.js

+ 20 - 1
js/inputmask.extensions.js

@@ -68,7 +68,7 @@ Optional extensions on the jquery.inputmask base
 				}
 				}
 			},
 			},
 			"email": {
 			"email": {
-			  //https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
+				//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
 				//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
 				//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
 				//should be extended with the toplevel domains at the end
 				//should be extended with the toplevel domains at the end
 				mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}[.-{1,63}][.-{1,63}][.-{1,63}]",
 				mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}[.-{1,63}][.-{1,63}][.-{1,63}]",
@@ -95,6 +95,25 @@ Optional extensions on the jquery.inputmask base
 			},
 			},
 			"mac": {
 			"mac": {
 				mask: "##:##:##:##:##:##"
 				mask: "##:##:##:##:##:##"
+			},
+			"vin": {
+				//https://en.wikipedia.org/wiki/Vehicle_identification_number
+				// see issue #1199
+				mask: "V{8}vV{4}9{4}",
+				definitions: {
+					'V': {
+						validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
+						cardinality: 1,
+						casing: "upper"
+					},
+					'v': {
+						validator: "[Xx\\d]",
+						cardinality: 1,
+						casing: "upper"
+					}
+				},
+				clearIncomplete: true,
+				autoUnmask: true
 			}
 			}
 		});
 		});
 		return Inputmask;
 		return Inputmask;