input Requirement : User will enter any number in the textBox. length maximum 11. may or may not contain '-'. eg: 123321123 or 12-33211-23
expected Result: the number should be formatted, displayed in the textBox as the user tabs-out of the textBox and should have '-' at the 4th and 8th position. eg : 123-321-123
I do not get the result as expected above.
<html>
<head>
<script type="text/javascript">
function formatMyId(id){
var value = window.document.getElementById(id).value;
var valueWithoutDashes = value.replaceAll("-","");
var formatted=valueWithoutDashes;
if(valueWithoutDashes.length==9){
formatted=insertAt(formatted,3,'-');
formatted=insertAt(formatted,7,'-');
What is happening? And what parts are working? Is the variable value receiving the correct element? Does valueWithoutDashes receive the expected result?
Eric, You are correct. thanks !!! I wrote my own replaceAll function inside the java script and it worked.
Bear, can you be a little polite while replying. I really appreciate your prompt reply. But a little politeness will be helpful.
Don't get me started about those stupid light bulbs.