JSFiddle - React, Tailwind, and code Playground
by mowglisanu
HTML
<input type="text" id="test"/>
JavaScript
(function($) {
function onlydigits(e) {
if (e.keyCode < 48 || e.keyCode > 58) {
return false;
}
}
function testpaste(e) {
console.log(e);
}
var methods = {
init: function(options) {
var settings = $.extend({
type: 'number',
range: {
lower: 0,
upper: 1000000
}
}, options);
this.data('settings', settings);
this.on('keydown', onlydigits);
this.on('paste change beforepaste afterpaste', testpaste);
},
destroy: function() {
}
}
$.fn.forms = function(options) {
return methods['init'].apply(this, options);
}
})(jQuery);
$('#test').forms({});