• Resolved Chandrakant

    (@mishrackant)


    Hi Developers

    I want to show the number in Indian System of grouping that is – …2,2,2,2,3 instead of 3,3,3,3.

    For example, the number 850654963 should be grouped as 85,06,54,963. Is it Possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @mishrackant

    Thank you very much for using our plugin. You can use the toLocaleString method.

    For example, assuming you have the equation fieldname1+fieldname2, and you want to return the result in Indian system, you can edit it as follows:

    (fieldname1+fieldname2).toLocaleString('hi-IN')

    Now, How to transform a value in Indian system to a valid javascript number to use in mathematical operations?

    For example, assuming the fieldname1 is in Indian System, and you want to use it in a mathematical operation, like fieldname1*3

    You can implement the equation as follows:

    (function(){
    var field = parseFloat((fieldname1|r).replace(/[^\d\.]/g, ''));
    
    return field*3;
    })()

    Note the use of the |r modifier with the field’s name. The plugin extracts numbers from fields values before evaluating the equations to use them in mathematical operations. But in your case, the default extraction of the plugin is not a solution. You need to get the field’s raw value to process it yourself. The |r modifier gives you access the field’s raw value, without preprocessing.

    If you want to the previous equation returns the value in Indian System, you can edit it as follows:

    (function(){
    var field = parseFloat((fieldname1|r).replace(/[^\d\.]/g, ''));
    
    return (field*3).toLocaleString('hi-IN');
    })()

    Best regards.

    Thread Starter Chandrakant

    (@mishrackant)

    Thanks for the Prompt Response. It worked perfectly for the calculated fields. But, How can I apply the Indian grouping system In the fields which don’t work with the equation?

    Regards

    Plugin Author codepeople

    (@codepeople)

    Hello @mishrackant

    In this case, you must use “Single Text Line” fields instead of number or currency fields (Currency and number fields make internal validation of their values), and insert and “HTML Content” field in the form to format the values yourself.

    For example, assuming you want to apply the format to some fields in the form.

    1. Assign a custom class name to those fields, Ex, indian-format

    The class names are assigned to the fields through their attributes “Add CSS Layout Keywords”

    2. Insert an “HTML Content” field in the form and enter the following piece of code as its content:

    
    <script>
    jQuery(document).on('change', '.indian-format input', function(){
        this.value = Number(String(this.value).replace(/[^\d\.]/g, '')).toLocaleString('hi-IN');
    });
    </script>

    Best regards.

    Thread Starter Chandrakant

    (@mishrackant)

    Hi CodePeople

    Thanks once again for the solution, It also worked. But, It would have been better, If we can implement the Indian format in currency, number and slider field. Now, I have to choose betwwen the slider and Indian grouping feature. I hope, you would give the Indian grouping option in future updates.

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Grouping of Numbers’ is closed to new replies.