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.
1
Expert's answer
2012-04-10T08:04:02-0400
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.
Comments
Leave a comment