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: README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
-
RestrictedTextField v1.3
1
+
RestrictedTextField v1.4 (UPCOMING RELEASE)
2
2
========================
3
3
4
+
# You've stumbled upon a development branch. Have a look around if you want, but only use code that's posted on the releases page.
5
+
4
6
See LICENSE for this software's licensing terms.
5
7
6
8
RestrictedTextField is a jQuery plugin which uses regular expressions to validate and control input to HTML text fields. Using 38 built-in types or types you define yourself, it allows you to suppress invalid keystrokes or to allow them into the field but be flagged incorrect. Validation is performed on keystroke, paste and blur.
@@ -11,6 +13,7 @@ RestrictedTextField is a jQuery plugin which uses regular expressions to validat
11
13
* Discard invalid keystrokes or catch a validation failure event to handle it as you wish
12
14
* Has 38 built-in types
13
15
* Extensible: define your own types
16
+
* Supports (but does not rely on) the HTML 5 `pattern` attribute - can be enabled during initialization
14
17
* Money types automatically format on blur to end in a decimal point and two digits
15
18
16
19
@@ -93,6 +96,7 @@ If you prefer not to use strictly-enforced credit card types (is Wikipedia corre
|`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 |
95
98
|`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 |
99
+
|`usePatternAttr`| When enabled, sets the HTML5 `pattern` attribute on the input field. Check [caniuse.com](http://caniuse.com/#search=pattern) for browser support. | boolean | true/false | false |
This section allows you to test drive RestrictedTextField's built-in types.<br/>
54
-
Select a type from the dropdown menu and use the checkbox to control whether invalid keystrokes are discarded.<br/>
55
-
Regardless of the checkbox state, validation is always performed on each keystroke and on blur.
56
-
</p>
57
52
58
-
<p>
59
-
This demo has event listeners that flash the text field's border when a keystroke is discarded, and colors its<br/>
60
-
border solid red if it contains an invalid character. The demo initializes RestrictedTextField with a logging<br/>
61
-
function, so you can open your browser's console to view events in real time.
62
-
</p>
53
+
<divid="instructions">
54
+
<p>Here you can test drive RestrictedTextField's built-in types. Select a type from the dropdown menu and use the checkboxes to further customize the configuration.</p>
55
+
56
+
<p>Regardless of the state of the "Discard invalid keystrokes" checkbox, validation is always performed on each keystroke and on blur.</p>
57
+
58
+
<p>This demo declares event listeners that flash the text field's border when a keystroke is discarded, and colors its border solid red if an invalid character is allowed into the field.</p>
59
+
60
+
<p>
61
+
To better demonstrate the support of the <ahref="http://caniuse.com/#search=pattern" target="_blank">pattern</a> attribute, the event listener which watches for invalid text
62
+
inside the field will be disabled when the pattern attribute is in use. You'll notice that with the pattern attribute, the browser's built-in behavior alters the field's border
63
+
color, but only on blur. Notice how this differs from RestrictedTextField's approach when the pattern attribute isn't turned on. Note: for types which require validation beyond
64
+
a regular expression (for example, a credit card number), the pattern attribute won't provide complete validation; you'll want to heed RestrictedTextField's validation events.
65
+
</p>
66
+
67
+
<p>The demo initializes RestrictedTextField with a logging function, so you can open your browser's console to view events in real time.</p>
0 commit comments