Answer to Question #4773 in AJAX | JavaScript | HTML | PHP for Lekshmipriya

Question #4773
Write a JavaScript that inputs the telephone number as a string in the form of (555) 555 – 5555. The script should use string method split to extract the area code as a token. The first three digit of the phone number as a token, the last four digits of the phone number as a token. Display the area code in one text field and seven digit phone numbers in another text field.
Expert's answer
var telephone = document.getElementById('telephone').split('(').join('');
var code = telephone.split(')')[0];
document.getElementById('first_text_field').value = code;
document.getElementById('second_text_field').value = telephone;

You must replace names in getElementById with real Id's of your project.

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!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog