0

I have a On VF page input field called Amount. If user typing 99999 then it must return 99,999 how do I achieve this.

Any help!!!

3

It can be achieve by using javascript :

EXPLANATION : This script will replace the number with comma after every 3 digits. Like 23,000,599,999. It will also allow you to enter a single . (dot) and will not allow you to add comma from your end.

    <script>        
    //This function is used to append comma with no after every 3 digit.
    function Comma(Num) { //function to add commas to textboxes
        Num += '';
        Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
        Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
        x = Num.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1))
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        return x1 + x2;
    }

</script>
From the input text call the function.  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.