JavaScript Objects Part 3: Validate Phone Number

Objectives

  • User types telephone number, as a string, in this format: (999) 999-9999
  • Use regular expression to validate the phone number
  • If the phone number typed is not in the correct format, an error message in the textarea shows the user the correct way to type the phone number
  • If the phone number typed is in the correct format, a message in the textarea thanks the user for their phone number and that the user should expect to be contacted by one of the agents in the future

Results




Part 1


Create a script that verifies user entry is a four decimal number and present calculations using Math.round, Math.sort, Math.floor, toFixed(), and parseFloat()

View Part 1

Part 2


Write a sccript that allows the user to enter long text into a textarea, then enter a single character in a separate input. The script will count how many times the single character is in the long text.

View Part 2

Part 3


Create a script that validates user input for a telephone number in (999) 999-9999 format.

View Part 3