Hirameck
05-09-2004, 08:34 PM
Hi!
I need to convert phone number.
If the phone number 1234567890 is entered, then on submit the number should be converted to (123)456-7890.
This what I got sofar.
function convert_telephone1() {
var temp7 = document.form1.telephone1.value;
temp7 = temp7.replace(temp7, /^\(?(\d{3})\)?[\.\-\/]?(\d{3})[\.\-\/]?(\d{4})$/); // Phone no. - Validation
document.form1.telephone1.value = temp7;
}
<input type="text" name="telephone1">
<input type="button" onClick="convert_telephone1();" value="Validate Phone number1">
* Could you also explain where I went wrong.
THANKS :mad:
I need to convert phone number.
If the phone number 1234567890 is entered, then on submit the number should be converted to (123)456-7890.
This what I got sofar.
function convert_telephone1() {
var temp7 = document.form1.telephone1.value;
temp7 = temp7.replace(temp7, /^\(?(\d{3})\)?[\.\-\/]?(\d{3})[\.\-\/]?(\d{4})$/); // Phone no. - Validation
document.form1.telephone1.value = temp7;
}
<input type="text" name="telephone1">
<input type="button" onClick="convert_telephone1();" value="Validate Phone number1">
* Could you also explain where I went wrong.
THANKS :mad: