You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,14 @@
1
+
# Release 1.1 (November 15, 2016)
2
+
3
+
* Fixes for money types
4
+
* All money types automatically format on blur: values will be updated, if necessary, to always end in a period followed by two digits
5
+
* Fixed issue with the int types which considered a negative sign by itself to be a valid value
6
+
* Relaxed the int and float types/subtypes, and added strict versions of each. The relaxed versions accept leading/trailing zeros and negative zero; the strict versions do not.
7
+
* Added a logging callback function as a configurable option
8
+
* Throws an exception if invoked on something other than an input element
9
+
* Added Selenium unit tests
10
+
11
+
1
12
# Release 1.0.1 (April 2, 2016)
2
13
3
14
* Minor under-the-hood improvement. No change to functionality.
ResrictedTextField is a jQuery plugin which enforces data formats on HTML text boxes. Data which doesn't match the declared format is rejected.
6
+
ResrictedTextField is a jQuery plugin which uses regular expressions to validate HTML text fields. It allows you to reject invalid keystrokes or to allow them into the field. Fields are always validated on blur.
7
7
8
8
9
9
## Features
10
10
11
11
* Prevent invalid keystrokes or catch a validation failure event to handle it as you wish
12
+
* Has 29 built-in types
13
+
* Extendible: define your own types
14
+
* Money types automatically format on blur to end in a decimal point and two digits
12
15
13
-
* Endlessly extendible: define your own types
14
-
* Features 23 built-in types:
16
+
17
+
## Built-in Types
15
18
16
19
1. Alpha strings
17
20
2. Uppercase alpha strings
@@ -28,22 +31,52 @@ ResrictedTextField is a jQuery plugin which enforces data formats on HTML text b
28
31
13. Integers
29
32
14. Positive integers
30
33
15. Negative integers
31
-
16. Floats
32
-
17. Positive floats
33
-
18. Negative floats
34
-
19. Money
35
-
20. Positive money
36
-
21. Negative money
37
-
22. Accounting money notation (negatives expressed by wrapping the value in parentheses)
38
-
23. Negative accounting money
34
+
16. Strict integers
35
+
17. Strict positive integers
36
+
18. Strict negative integers
37
+
19. Floats
38
+
20. Positive floats
39
+
21. Negative floats
40
+
22. Strict floats
41
+
23. Strict positive floats
42
+
24. Strict negative floats
43
+
25. Money
44
+
26. Positive money
45
+
27. Negative money
46
+
28. Accounting money notation (negatives expressed by wrapping the value in parentheses)
47
+
29. Negative accounting money
48
+
49
+
50
+
## What's the difference between integer/strict integer, float/strict float?
51
+
52
+
### Integer types:
53
+
54
+
* Zero can be negative
55
+
56
+
### Strict integer types:
57
+
58
+
* Zero cannot be negative
59
+
60
+
### Float types:
61
+
62
+
* Integers are valid
63
+
* Zero is valid (0, 0.0, .0, 0000.000, etc.)
64
+
* Zero can be negative
65
+
66
+
### Strict float types:
67
+
68
+
* Values must be floating-point
69
+
* Zero is valid (0.0, .0, 0000.000, etc.)
70
+
* Zero cannot be negative
39
71
40
72
41
73
## Configuration
42
74
43
75
| Property | Description | Data Type | Valid Values | Default Value |
|`type`| Text field type. This is a required setting. | string | alpha, upperAlpha, lowerAlpha, alphaSpace, upperAlphaSpace, lowerAlphaSpace, alphanumeric, upperAlphanumeric, lowerAlphanumeric, alphanumericSpace, upperAlphanumericSpace, lowerAlphanumericSpace, int, positiveInt, negativeInt, strictInt, strictPositiveInt, strictNegativeInt, float, positiveFloat, negativeFloat, strictFloat, money, positiveMoney, negativeMoney, accountingMoney, negativeAccountingMoney| null |
46
78
|`preventInvalidInput`| When enabled, invalid keystrokes are ignored (the value of the text field is not updated). When disabled, invalid keystrokes are not ignored. | boolean | true/false | true |
79
+
|`logger`| An optional callback function for logging. If you want to enable logging, provide a function and then do whatever you wish with the message. | function | A function accepting the log message as a string argument | undefined |
47
80
48
81
49
82
## Events
@@ -54,7 +87,7 @@ These events are fired based on the state of the text field.
| inputIgnored | Fires when an invalid keystroke is ignored. `preventInvalidInput` must be enabled for this event to fire. |
56
89
| validationFailed | Fires when an invalid keystroke is made when `preventInvalidInput` is disabled. Also fires if validation performed on blur() fails. |
57
-
| validationSuccess | Fires when the user removes invalid data when `preventInvalidInput` is disabled. Also fires if validation performed on blur() passes. |
90
+
| validationSuccess | Fires when the user removes invalid data when `preventInvalidInput` is disabled. Also fires if validation performed on blur() succeeds. |
This plugin has only been tested on desktop browsers. Mobile testing might happen in the future. As for desktop browsers, many other versions of Firefox and Chrome, whether older or newer than what's listed here, are certainly compatible. Browsers not listed here might work fine, but have not been tested.
76
111
77
-
* Firefox 45.0.1: Compatible
78
-
* Chrome 49.0.2623.108 m: Compatible
112
+
* Firefox 49.0.2: Compatible
113
+
* Chrome 54.0.2840.99 m: Compatible
79
114
* Edge: Compatible
80
115
* IE 11: Compatible
81
116
* IE 10: Compatible
82
117
* IE 9: Compatible
83
118
* IE 8: INCOMPATIBLE
84
119
85
120
121
+
# Running the Unit Tests
122
+
123
+
[Selenium](http://www.seleniumhq.org) is used for unit testing in order to generate true keypresses in a text field. A JavaScript-based framework (such as QUnit, etc.) would have made life simpler, but synthetic JavaScript events don't carry out the actual actions associated with them. In other words, simulating a keypress fires the correct events, but doesn't result in actual text being written to a text field. This is a security restriction of JavaScript. As a result, this project uses Selenium and JUnit.
124
+
125
+
1. Install the following build dependencies:
126
+
*[Node.js](https://nodejs.org/en)
127
+
*[Gradle](http://gradle.org)
128
+
*[Java JDK](http://www.oracle.com/technetwork/java/javase/index.html) version 8 or later
2. Modify the `buildScriptsDir` property in `SeleniumTester/gradle.properties` to reflect the location of BuildScripts on your filesystem
131
+
3. Download the appropriate browser drivers for your system at [seleniumhq.org](http://www.seleniumhq.org). Once you've downloaded them, update `geckoDriverPath`, `edgeDriverPath`, `ieDriverPath` and `chromeDriverPath` in `SeleniumTester/gradle.properties` with their paths.
132
+
4. If you're testing in IE, set Protected Mode to the same value in all zones (it doesn't matter whether it's set to enabled or disabled, just that it's the same for all). See [here](http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html) for more information. If that page disappears from the Web, see [the Wayback Machine's copy](http://web.archive.org/web/20151026094711/http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html).
133
+
5. Set your browsers' zoom levels to 100%. If you don't, Selenium will throw an exception, at least for IE.
134
+
6. Update the `browsers` property in `SeleniumTester/gradle.properties` to reflect which browsers you'll be testing with. This is explained further by documentation found in the properties file.
135
+
7. Now, from a command prompt:
136
+
1.`cd` to the project root (`jquery-RestrictedTextField`)
137
+
2. Type `npm install`
138
+
3. Type `npm test`
139
+
140
+
141
+
#### UNIT TESTS GOTCHAS:
142
+
143
+
*#### The Selenium project's 64-bit IE driver is broken for IE 10 and 11, and according to a Selenium contributor, is unfixable. See [here](https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/5116) and [here](http://jimevansmusic.blogspot.com/2014/09/screenshots-sendkeys-and-sixty-four.html). If you're testing on a 64-bit version of Windows with IE 10 or 11, use the 32-bit driver instead. Its performance is still quite poor, but is far better than the 64-bit driver.
144
+
145
+
*#### If you're using Windows and if you haven't used Selenium before, Windows Firewall will pop up an alert asking whether to allow driver servers to listen for connections. You need to grant these permissions. During this time, one or more of the unit tests will fail. Simply re-run the tests after the permission has been granted.
146
+
147
+
*#### If you're running the unit tests in Firefox, you must use Firefox 48 or later. Starting with Firefox 48, Selenium is required to use the Marionette/Gecko driver, and my code is written to initialize that particular driver. Although RestrictedTextField itself is supported on older Firefox releases, the unit tests are not.
148
+
149
+
*#### If you're running the unit tests in Firefox, the last known Gecko driver which worked was v0.10.0. Sometime after that, something happened in the Gecko driver which messes up the tests' ability to trigger blur events, which results in practically every test failing. Version 0.11.1 (November, 2016) is confirmed to cause this problem. No later version of the Gecko driver has been tested.
150
+
151
+
*#### It's critical that you do not interact with the machine in any way while tests are running. Being that this plugin is event-driven, any action that could cause an event to be fired unexpectedly could cause tests to fail. This includes human actions, but also includes applications popping up notifications or asserting themselves in other ways. To the extent possible, you should take steps to minimize this possibility.
152
+
153
+
*#### The tests fail in Edge if Edge doesn't have focus. Sometimes Edge opens behind another window (for example, the console which you might have used to invoke the tests).
154
+
155
+
86
156
## Thanks
87
157
88
-
Do you like this library? Want to toss a few bucks my way to say thanks? I accept donations at https://paypal.me/KurtisLoVerde/5. Thank you for your support!
158
+
Do you like this software? Want to toss a few bucks my way to say thanks? I accept donations at https://paypal.me/KurtisLoVerde/10. Thank you for your support!
0 commit comments