EVENTO CLICK INPUT TYPE NUMBER CON ENTER KEY 13 FORMATO MONEDA JS

var number = 123456.789;

var number2 = 123456;


console.log(new Intl.NumberFormat('es-AR', {currency: 'ARS', style: 'currency'}).format(number));

console.log(new Intl.NumberFormat('es-CL', {currency: 'CLP', style: 'currency'}).format(number2));










<!--<input type="number" onkeyup="someFunction()"  oninput="someFunction()" />-->


<input type="number"   oninput="someFunction(this.value)" value="1" />


<br><br>

<input  onkeypress="return sendChatMessage(event,this.value)">



<input type="text" id="b" onfocus="seleccion();" autocomplete="off" style="width: 250px;border: 1px solid #919191;border-radius: 8px;color:black;background:#f5e3c7;">



<script>


function seleccion() {


document.getElementById('b').select();


}




function someFunction(x) {

  alert(x);

}



function sendChatMessage(e,x) {

    if (e.which == 13 || e.keyCode == 13) {

        e.preventDefault();


        alert(x);


        console.log("e.keyCode == 13"); 

        return false;

    }

    return true;

}


parseFloat(producto.precio).toFixed(2)


const result1 = num1.toFixed(2);

console.log(result1); //  13.51


// ------------------------------------


const num2 = 13.504;

const result2 = num2.toFixed(2);

console.log(result2); //  13.50


// ------------------------------------


const str1 = '13.1';

const result3 = parseFloat(str1).toFixed(2);

console.log(result3); //  13.10



num.toFixed(2).replace('.00', '');


</script>

/////////////////////////////////////



 //console.log(round2Fixed(10.8034)); // Returns "10.80"

 //console.log(round2Fixed(10.8));



console.log(Number(1.00).toFixed(2));         // 1.00

console.log(Number(1.341).toFixed(2));     // 1.34

console.log(Number(1.345).toFixed(2));     // 1.34 NOTE: See andy's comment below.

console.log(Number(1.3450001).toFixed(2)); // 1.35



var num11 = 99.345;

console.log(num11.toLocaleString("es-AR", { maximumFractionDigits: 10, minimumFractionDigits: 2 }));







const currencyFractionDigits = new Intl.NumberFormat('de-DE', {

    style: 'currency',

    currency: 'EUR',

}).resolvedOptions().maximumFractionDigits;


const value = (12345.678).toLocaleString('de-DE', {

    maximumFractionDigits: currencyFractionDigits 

});


console.log(value); // prints 12.345,68


/***********************************************************/


var number = 123456.789;


function getCurrencySymbol(locale, currency) {

  return (0).toLocaleString(locale, {

    style: 'currency',

    currency: currency,

    minimumFractionDigits: 0,

    maximumFractionDigits: 0

  }).replace(/\d/g, '').trim();

}

var numeric_format = new Intl.NumberFormat('id-ID', { style: 'currency', currency: 'IDR', currencyDisplay: 'symbol' });

var localCurrencySymbol  = getCurrencySymbol('id-ID', 'IDR');

var CurrencySymbolNeedle = new RegExp(localCurrencySymbol, "g");


var amount = numeric_format.format(number);

console.log(localCurrencySymbol); // Rp

console.log(amount); // Rp 123.456,79

amount = amount.replace(CurrencySymbolNeedle, '').replace(/\s+/g, '');

console.log(amount); // 123.456,79




/***************************************/



const s = 1234.967 ;

const options = { minimumFractionDigits: 2, maximumFractionDigits: 2 }

const result = new Intl.NumberFormat('pt-BR', options).format(s);


console.log(result);



/*

const val = 1234.56 ;

var result = val.toLocaleString('es-AR', {

    style: 'currency',

    currency: 'ARS',

    minimumFractionDigits: 2

});


console.log(result); // Prints "$1.234,56"

*/


/*

 numeral('87.75').format('$0.0,00')

'$87.7500'

> numeral('87.75').format('$0,0.00')

'$87.75'

> numeral('87.75').format('$0,00')

'$88'

> numeral('87.75').format('$0.00')

'$87.75'

> numeral('87.75').format('$00,00')

'$88'

> numeral('87.75').format('$0.00')

'$87.75'

> numeral('87.75').format('$00,00')

'$88'

> numeral('87.75').format('$00,00.00')

'$87.75'

> numeral('87.75').format('$0[.]0.00')

'$87.8'

> numeral('87.75').format('$0[.]0[.]00')

'$87.8'

> numeral('87.75').format('$0[.]0[,]00')

'$87.75'

> numeral('87.75').format('$0[,]0[,]00')

'$88'

*/


console.log(numeral('87.75').format('$0.00'));








/*



const num1 = 13;


const result1 = num1.toFixed(2);


console.log(result1); //  13.51


console.log(num1.toFixed(2).replace('.00', ''));



// ------------------------------------


const num2 = 13.504;

const result2 = num2.toFixed(2);

console.log(result2); //  13.50


// ------------------------------------


const str1 = '13.1';

const result3 = parseFloat(str1).toFixed(2);

console.log(result3); //  13.10

*/




Comentarios

Entradas populares de este blog

INSERTAR Y UPDATE FECHA CON PHP MYSQL EN FORMULARIO METODO POST CON JQUERY ETIQUETA DATE

Copia de Seguridad de Archivo MS Access (.mdb) a Pendrive con VB6

CONVERTIR IMÁGEN JPG O PNG A WEBP CON PHP DE FORMA SIMPLE