Adding comma separator to integer field in form

Kentico Dev1 asked on June 12, 2018 16:17

Using K10 and created a custom form with some tables and values that will be input by end user. The values are integer data type, but would like to be able to add comma separator (basic masking) at every 3rd digit: 1,000 and 1,000,000 on the form as the user types it in vs 1000 and 1000000. Would even be able to accpe adding the comma after user tabs/moves to next field.

Found this formatting note earlier: string.Format("${0:#,##0.00}", Eval

Recent Answers


Rui Wang answered on June 12, 2018 16:33

if the data type is integer, I don't see how you can store comma in the data. But you can consider doing this on the client side using JS during data entry or display. https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript

0 votesVote for this answer Mark as a Correct answer

Kentico Dev1 answered on October 16, 2018 15:41

I think maybe I misspoke. I dont need the number to be stored with the commas - agreed that would make it a string. But the forms in Kentico dont seem to allow for any kind of dynamic formatting or masking as end users key values in. It also appears that adding JS to a form would require custom development and altering the form, correct? There isnt anywhere to put the JS in the link you provided unless its on in the code that was generated by code generator tool?

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on October 16, 2018 15:50

You can add a JavaScript web part into the template that you are using to display the form.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.