Two Mode Currency Format is a format that has two mode, 1. Replace mode s a mode that has fixed format (masking) which is the character will replaced by character of keystroke. So the value will not increase.2. Non replace mode is a mode that will put the pointer in a fixed position so when we enter the character so the value of the TextBox will increase. I’m using createRange function in javascript to make this kind of format. createRange is a function/class that will make one or more cursor selection in a document. When we call select() function then automatically cursor will select the character from the first position of cursor until the end of cursor selection which is set when we call moveEnd function.
Example :
var docrng = document.selection.createRange();
docrng.collapse();
docrng.moveStart(‘character’, 0);
docrng.moveEnd(‘character’, 1);
docrng.select();
As you see in the example above that we make the instance of document createRange and then we call collapse() function to make the selection is collapse, then we set first position the cursor selection by calling moveStart function and last position of cursor selection by calling moveEnd function. That is the basic function that I have been use to make this Two Mode Currency Format, to see the whole source code you can download it (SourceCode.zip).