Answer to Question #3654 in AJAX | JavaScript | HTML | PHP for srujana

Question #3654
Write a script that inputs a telephone number as a string in the form (555)555-5555. The script should use String method split to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. Display the area code in one text field and the seven-digit phone number in another text field.
1
Expert's answer
2011-07-19T10:17:36-0400
var p=window.prompt("Enter the phone in the form (XXX)XXX-XXXX",""); var code=p.split(")")[0].split("(")[1];
var p1=p.split(")")[1].split("-")[0];
var p2=p.split(")")[1].split("-")[1];
document.write("");
document.write("Code:
"); document.write("Phone:
"); document.write("");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

harini
28.07.11, 20:50

For the above code the output is not generating...need help

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS