script that autimatically enters a the specified character at a certain point in a text box
-
Suggested improvement to: a script that autimatically enters a the specified character at a certain point in a text box By webProgrammer Posted: 12 Aug 2003 This script could be improved with the addition of a line to detect and permit the use of the backspace key: function mask(str,textbox,loc,delim){ var locs = loc.split(','); for (var i = 0; i <= locs.length; i++){ for (var k = 0; k <= str.length; k++){ if (k == locs[i]){ if (str.substring(k, k+1) != delim){ if (event.keyCode != 8) //backspace str = str.substring(0,k) + delim + str.substring(k,str.length); } } } } textbox.value = str }
-
Suggested improvement to: a script that autimatically enters a the specified character at a certain point in a text box By webProgrammer Posted: 12 Aug 2003 This script could be improved with the addition of a line to detect and permit the use of the backspace key: function mask(str,textbox,loc,delim){ var locs = loc.split(','); for (var i = 0; i <= locs.length; i++){ for (var k = 0; k <= str.length; k++){ if (k == locs[i]){ if (str.substring(k, k+1) != delim){ if (event.keyCode != 8) //backspace str = str.substring(0,k) + delim + str.substring(k,str.length); } } } } textbox.value = str }
thanks for the addition, I was about to add that myself, when I noticed your addition/fix.