Jump to content

Rule to add spaces in numbers


kleland

Recommended Posts

Hi, I'm trying to format a 10-digit number with internal spaces. In other words, my number 0000000000 should be output as 000 0000 000. I tried the FormatNumber rule but it does not take spaces as characters(?). Any ideas on how to do this would be appreciated.
Link to comment
Share on other sites

Assuming your input is always going to be 10 digits you could try something like:

var example = "1234567890";
return example.substr(0,3) + " " + example.substr(3,4) + " " + example.substr(7,3);

 

Just replace the example variable with your input field.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...