http://digitalbush.com/projects/masked-input-plugin/#demo

Untitled Document

function phone_fill()
{
var phone_val = document.getElementById(‘phone’).value;
if(phone_val.length%3 ==0)
{
phone_val += ‘-‘;
alert(phone_val);
}
}