Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(".cjs-limite-decimales").keyup(function(){
- var total = $(this).val();
- var separador;
- if(total.indexOf(",") != -1){
- separador = ",";
- }
- else if(total.indexOf(".") != -1){
- separador = ".";
- }
- if(separador){
- var decimales = total.split(separador);
- if(decimales[1].length > 2){
- decimales[1] = decimales[1].substr(0, 2);
- }
- total = decimales.join(separador);
- }
- $(this).val(total);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement