Is there a way I can format for example: 0000000000 into (000)000-0000? I'm returning a listbox which holds a collection of phone number which arent formated yet. What I would like is format it. This is what I have in the View:
<%= Html.ListBox("phoneList")%>
and from the controller:
ViewData["phoneList"] = new SelectList(phoneList);
Edit
$('#phoneList').each(function() {
var phoneNumber = $(this).text();
var formatPhoneNumber = phoneNumber.replace(/(\d{3})(\d{3})(\d{4})/, '($1)$2-$3');
alert(formatPhoneNumber);
});
how would I assign this back to show in the ListBox?