web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

thousand separator with javascript on keyup event in crm

(0) ShareShare
ReportReport
Posted on by

hi, 

i have a problem in crm , first i design form with decimal format but our value more than 100,000,000,000 

and crm have validation in decimal number , and i force to use single line text field instead , and convert to decimal in my plugin and everything is ok , except one issue , in decimal field we have camma seprator  for number by default when user input the number , i need a javascript code that do something like that , which dose not affect to save on field becuase i dont like run my plugin for lots of records that imported in crm , i just need to show seprator to text field when keyup on field or when form is loading , could you please help me , it's very force  and i try  with some jQuery code  and i did not answer yet ,

i need something like this format in c# in ToString 

ToString("#,##0.00")

but in Javascript in KeyUp Event and loading Time 

thanks for your attention 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: thousand separator with javascript on keyup event in crm

    Hi Somyaeh,

    Your understanding is correct , You should set the JS function on change and onload method and you can remove the comma by using another JS function in onsave event where you can set the without comma value or you can remove the comma using plugin.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: thousand separator with javascript on keyup event in crm

    Yes, so you need an onload & onchange to show the comma. You can remove the comma from plugin but I guess then it will show the updated value i.e. without comma as on save onload doesn't trigger. Have you thought of capturing the values in 2 different field 1 with comman and other with not comma. So on form you will show the value with commas' and additional logic to put the same valye in your actual field without the comma. This way you will have both the values.

  • Community Member Profile Picture
    on at
    RE: thousand separator with javascript on keyup event in crm

    but if i remove it in onsave user dont see coma again ?

    i think i must set comma as you told in onload and onchange and save it and in my plugin remove the comma,

    but for old imported record  could i that record in sql  ?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: thousand separator with javascript on keyup event in crm

    Hi,

    Thank you can write the code onchange  event and amrk the field isdirty false. This way, the value will be shown with comma but because it is not dirty it wont be saved.

    Hipe this helps.

  • Community Member Profile Picture
    on at
    RE: thousand separator with javascript on keyup event in crm

    thanks all firends , all answer are true but ,because i import more than 10000 record in crm entity with out comma and run plugin on it , i like just show comma at on load or  on change but i dont like save comma on those record ?  

  • Verified answer
    balakrishna uppala Profile Picture
    570 on at
    RE: thousand separator with javascript on keyup event in crm

    Hi,

    You can write code as Ravi/Goutam mentioned to set commas, but you can trigger that onFormLoad and OnChange functions.

    In addition to that you can write a simple function to Remove Comma(,) from text and can trigger it OnSave event.(As you don't want to save Commas).

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: thousand separator with javascript on keyup event in crm

    Hi,

    It would be difficult to achieve this using onkeyup as once the comma is added it would not be a number any more. You could try onchange just like crm does for decimal fields.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: thousand separator with javascript on keyup event in crm

    Hi Smayeh ,

    You can do the same using onchange event of the field, as dynamics CRM does not support onkeyup functionality.

            function OnChangeTextField() {
                var x = Xrm.Page.getAttribute("TextFieldName").getValue();
                var y = x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                Xrm.Page.getAttribute("TextFieldName").setValue(y);
            }


  • Community Member Profile Picture
    on at
    RE: thousand separator with javascript on keyup event in crm

    i dont like save value with comma seprator , i want only show with this format or when type number in text field

  • Community Member Profile Picture
    on at
    RE: thousand separator with javascript on keyup event in crm

    thanks for your reply ,

    i want some code that when i type in text field change it with seprator ,

    i need keyup event in crm  with javascript ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans