I am creating my first jQuery plugin that automatically formats numbers in various international formats. Inside the plug-in there are a couple of functions that break lines and reformat the line, which should be called from another jQuery script.
Based on the structure of the plug-in below (let me know if you need all the code), can I call and send parameters to stripFormat(ii)and functions targetFormat(ii, iv)?
Or do I need to change my plug-in structure, and if so, how?
(function($){
var p = $.extend({
aNum: '0123456789',
aNeg: '-',
aSep: ',',
aDec: '.',
aInput: '',
cPos: 0
});
$.fn.extend({
AutoFormat: function() {
return this.each(function() {
$(this).keypress(function (e){
code here;
});
$(this).keyup(function (e){
code here;
});
function stripFormat(ii){
code here;
}
function targetFormat(ii, iv){
code here;
}
});
}
});
})(jQuery);
Ways to call plug-in functions:
jQuery(function(){
$("input").change(function (){
document.getElementById(targetElementid).value = targetFormat(targetElementid, targetValue);
});
});
I tried to use these options without success:
document.getElementById(targetElementid).value = $.targetFormat(targetElementid, targetValue);
document.getElementById(targetElementid).value = $.autoFormat().targetFormat(targetElementid, targetValue);
source
share