function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $key => $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return (object) $haystack[$key];
}
}
return false;
}
Thursday, February 9, 2017
Input Amount jQuery Plugin
/*
Name:input_amount
Author:Reyneil Lato
Date:February 09, 2017
Time:04:47PM
Version:1.0
Description: amount formatter
*/
(function($){
$.fn.input_amount = function(options) {
// defaults
var defaults = {
decimal : 2
};
var options = $.extend(defaults, options);
return this.each(function(){
jQuery(this).on("keypress keyup blur keydown",function(event) {
var t = jQuery(this).val();
// prevent letters and arrow
if((event.which >= 65 && event.keyCode <= 90) || (event.which >= 37 && event.which <= 40) || event.which == 32){
event.preventDefault();
}
// only 1 decimal point and 2 decimal places
if(t.indexOf(".") != -1){
var dec = t.toString().split(".");
if((event.which == 190 || event.which == 110) || (dec[1].length >= parseInt(options.decimal) && event.which != 8)){
event.preventDefault();
}
}
// format with commas every 3 digit
jQuery(this).val(function(index, value) {
var c = value.toString();
if(c.indexOf(".") != -1){
var x = c.split(".");
x[0] = x[0].toString().replace(/,/gi, "");
x[0] = x[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.join(".");
}
else{
var z = c.toString().replace(/,/gi, "");
z = z.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return z;
}
});
});
});
};
})(jQuery);
Name:input_amount
Author:Reyneil Lato
Date:February 09, 2017
Time:04:47PM
Version:1.0
Description: amount formatter
*/
(function($){
$.fn.input_amount = function(options) {
// defaults
var defaults = {
decimal : 2
};
var options = $.extend(defaults, options);
return this.each(function(){
jQuery(this).on("keypress keyup blur keydown",function(event) {
var t = jQuery(this).val();
// prevent letters and arrow
if((event.which >= 65 && event.keyCode <= 90) || (event.which >= 37 && event.which <= 40) || event.which == 32){
event.preventDefault();
}
// only 1 decimal point and 2 decimal places
if(t.indexOf(".") != -1){
var dec = t.toString().split(".");
if((event.which == 190 || event.which == 110) || (dec[1].length >= parseInt(options.decimal) && event.which != 8)){
event.preventDefault();
}
}
// format with commas every 3 digit
jQuery(this).val(function(index, value) {
var c = value.toString();
if(c.indexOf(".") != -1){
var x = c.split(".");
x[0] = x[0].toString().replace(/,/gi, "");
x[0] = x[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.join(".");
}
else{
var z = c.toString().replace(/,/gi, "");
z = z.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return z;
}
});
});
});
};
})(jQuery);
Wednesday, February 8, 2017
revert old firebug
browse
about:config
search
browser.tabs.remote.autostart,
browser.tabs.remote.autostart.1
browser.tabs.remote.autostart.2
and change all values to false
about:config
search
browser.tabs.remote.autostart,
browser.tabs.remote.autostart.1
browser.tabs.remote.autostart.2
and change all values to false
jQuery input amount format
jQuery(selector).on("keypress keyup blur keydown",function(event) {
var t = jQuery(this).val();
// prevent letters and arrow
if((event.which >= 65 && event.keyCode <= 90) || (event.which >= 37 && event.which <= 40) || event.which == 32){
event.preventDefault();
}
// only 1 decimal point and 2 decimal places
if(t.indexOf(".") != -1){
var dec = t.toString().split(".");
if((event.which == 190 || event.which == 110) || (dec[1].length >= 2 && event.which != 8)){
event.preventDefault();
}
}
// format with commas every 3 digit
jQuery(this).val(function(index, value) {
var c = value.toString();
if(c.indexOf(".") != -1){
var x = c.split(".");
x[0] = x[0].toString().replace(/,/gi, "");
x[0] = x[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.join(".");
}
else{
var z = c.toString().replace(/,/gi, "");
z = z.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return z;
}
});
});
var t = jQuery(this).val();
// prevent letters and arrow
if((event.which >= 65 && event.keyCode <= 90) || (event.which >= 37 && event.which <= 40) || event.which == 32){
event.preventDefault();
}
// only 1 decimal point and 2 decimal places
if(t.indexOf(".") != -1){
var dec = t.toString().split(".");
if((event.which == 190 || event.which == 110) || (dec[1].length >= 2 && event.which != 8)){
event.preventDefault();
}
}
// format with commas every 3 digit
jQuery(this).val(function(index, value) {
var c = value.toString();
if(c.indexOf(".") != -1){
var x = c.split(".");
x[0] = x[0].toString().replace(/,/gi, "");
x[0] = x[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.join(".");
}
else{
var z = c.toString().replace(/,/gi, "");
z = z.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return z;
}
});
});
Subscribe to:
Posts (Atom)