Script
jQuery(function($){
$('#phone').bind('keyup blur',function(){
var txt = $(this).val();
var txtRep = txt.replace(/-/g,'');
var txtLength = txtRep.length;
if(txt && txtLength>0){
if(txtLength===10 || txtLength===11){
if(txt.match(/\d+-?\d+-?\d+/)){
$(this).next().remove().end().after('<span class="ok">valid</span>');
}else{
$(this).next().remove().end().after('<span class="err">invalid</span>');
}
}else{
$(this).next().remove().end().after('<span class="err">invalid</span>');
}
}else{
$(this).next().remove();
}
});
});
Demo