Ron Hinds
16 years ago
What am I doing wrong with this code? I'm trying to parse a phone number
down to just the digits, irrespective of how the user enters it.
var phone;
var re;
phone = document.Register.Phone.value;
re = new RegExp("\D", "ig");
phone = phone.replace(re, "");
alert("Phone=" + phone);
The alert always shows the value of phone to be the same as whatever I typed
in the form, e.g., (702) 555-1212.
down to just the digits, irrespective of how the user enters it.
var phone;
var re;
phone = document.Register.Phone.value;
re = new RegExp("\D", "ig");
phone = phone.replace(re, "");
alert("Phone=" + phone);
The alert always shows the value of phone to be the same as whatever I typed
in the form, e.g., (702) 555-1212.