w2ui
Home
Get started
Demos
Docs
Blog
Support
Layout
Grid
Toolbar
Sidebar
Tabs
Form
Popup
Utilities
ver 1.3
ver 1.4
ver 1.5
ver 2.0
Form
Overview
Events
Properties
Methods
Fields
Numeric
Date & Time
Drop Lists
Multi Selects
Upload
Custom
Custom Types
If built-in types are not enough for you, there is a way you can create custom types.
$().w2field('addType', 'myType', function (options) { $(this.el).on('keypress', function (event) { if (event.metaKey || event.ctrlKey || event.altKey || (event.charCode != event.keyCode && event.keyCode > 0)) return; var ch = String.fromCharCode(event.charCode); if (ch != 'a' && ch != 'b' && ch != 'c') { if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; return false; } }); $(this.el).on('blur', function (event) { // keyCode & charCode differ in FireFox var ch = this.value; if (ch != 'a' && ch != 'b' && ch != 'c') { $(this).w2tag(w2utils.lang("Not a single character from the set of 'abc'")); } }); });
After you defined this type, you can apply it in the following way:
$('#id').w2field('myType');
User Comments
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus