I currently use the script below to take any form of information and pull out the numbers to make a phone number with dashes in it. However, if I accidently click in the field, it puts two dashes in there even though nothing was pasted or typed. Does JS have a way to say ONLY if something is pasted then add dashes? The reason it's a pain is I have 2 search fields, and if I want to use one, the other has to be blank. So if there are 2 dashes in it, I have to delete them out and hit enter in the same field or it will add them again. 

I appreciate any help you might have.

```
<SCRIPT LANGUAGE="JavaScript">
    function addDashes(f)
    {
        f.value = f.value.replace(/\D/g, '');
        f.value = f.value.slice(0,3)+"-"+f.value.slice(3,6)+"-"+f.value.slice(6,15);
    }
</SCRIPT>

```