Question: I am trying to input a telephone number in an input box like this (ex. 111-222-3333)

so I use this code:

```
<script type="text/javascript">
    function validate(evt) {
      var theEvent = evt || window.event;
      var key = theEvent.keyCode || theEvent.which;
      key = String.fromCharCode( key );
      var regex = /[0-9]|\-/;
      if( !regex.test(key) ) {
        theEvent.returnValue = false;
        if(theEvent.preventDefault) theEvent.preventDefault();
     }
    }
</script>

```

I can now only input telephone number using integer(0-9) and '-' but the problem is user can also type another hyphen(‐) after a hyphen(‐).
Or user can type numbers not in a telephone format

Please help me, i really need this one..thanks:)

Answer: 
You could use an alternate framework such as <http://alexgorbatchev.com/SyntaxHighlighter/>

Or take a look here and find something that suites.
<http://www.1stwebdesigner.com/css/16-free-javascript-code-syntax-highlighters-for-better-programming/>
Adding a new answer to an old question. 

I wanted to display line numbers in the left margin the way ace.js does.

My solution has some hacky details, but I wanted to share it anyway, because it turns out that absolute-positioned spans within relative-positioned spans work pretty well for this.

Encouraged by the above answers and [this answer about relative positioning without taking up space](https://stackoverflow.com/a/6040258/676195), I used:

```
var line = 1;
code = code.replace(/^/gm, function() {
    return '<span class="line-number-position">&#x200b;<span class="line-number">' + line++ + '</span></span>';
});

```

The regular expression `/^/gm` "replaces" the beginning of each line with the span-within-span.

`&#x200b;` is a zero-width space, because apparently firefox seems to have trouble deciding whether to put a zero-height span at the top or the bottom of the character.

`line-number-position` and `line-number` are CSS classes like these:

```
.line-number-position {
    position: relative;
    top: 0;
}

.line-number {
    position: absolute;
    text-align: right;
    right: 17px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 12px;
}

```

Yes, there are some magic numbers in there to match ace formatting, but the point is to put a relative-positioned zero-sized span at the beginning of each line and use it as a reference point to add an absolute-positioned span out in the left margin.

Works on current Chrome, Safari, Firefox, and Opera.