Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Formatta l'importo di testo passato in input.
- * Ritorna l'importo numerico formattato.
- *
- * @param {String} importo in stringa
- * @param {int} nDec - numero decimali, se non passato utilizza il n. defualt configurato lato server
- * @function
- */
- function formattaTestoImporto(text, nDec) {
- if (nDec != null) {
- var formato = creaFormatoByDecimali(nDec);
- return jQuery.formatNumber(text, { format: formato });
- } else {
- return jQuery.formatNumber(text);
- }
- }
- //es. formattaTestoImporto(55.5) -> return "55,50"
- ---------------------------
- /**
- * Deformatta il testo passato in input.
- * Ritorna l'importo numerico (Number) deformattato (9999.00).
- * In caso di errore ritorna null
- *
- * @param {String} text - importo in stringa
- * @function
- */
- function deformattaTestoImporto(text) {
- var number = null;
- try {
- number = jQuery.parseNumber(text);
- } catch (error) {
- return null;
- }
- return number;
- }
- // es . deformattaTestoImporto('99.999,00') -> return 99999;
- // deformattaTestoImporto('555,85') -> return 555.85
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement