Skip to content

reyrove/telephone-number-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telephone Number Validator

A simple, clean web application that validates whether a given phone number is a valid US number.

Live Demo

Features

  • Real-time phone number validation
  • Validates US phone number formats
  • Clear button to reset results
  • Handles various valid formatting patterns
  • User-friendly interface

How It Works

  1. Enter a phone number in the input field
  2. Click the "Check" button to validate
  3. The application will display whether the number is valid or invalid
  4. Use the "Clear" button to reset the result

Valid Phone Number Formats

The validator accepts the following US phone number formats:

  • 555-555-5555
  • (555)555-5555
  • (555) 555-5555
  • 555 555 5555
  • 5555555555
  • 1 555-555-5555
  • 1 (555) 555-5555
  • 1 555 555 5555
  • 1 5555555555
  • 1(555)555-5555

Technologies Used

  • HTML5
  • CSS3
  • JavaScript (Regular Expressions)

Installation

  1. Create a new folder on your computer
  2. Save the following files in that folder:
    • index.html (the HTML structure)
    • styles.css (the styling)
    • script.js (the JavaScript logic)
  3. Open index.html in any modern web browser

File Structure

telephone-number-validator/
├── index.html
├── styles.css
├── script.js
├── README.md
├── LICENSE
└── .gitignore

Usage Examples

Input Result
555-555-5555 Valid US number
(555)555-5555 Valid US number
1 555-555-5555 Valid US number
555-555-555 Invalid US number
5555555 Invalid US number
abc-def-ghij Invalid US number

Validation Rules

  • Empty input: Shows alert message
  • Valid US format: Displays "Valid US number"
  • Invalid format: Displays "Invalid US number"
  • Clear button: Removes result message

Browser Support

Works on all modern browsers including:

  • Google Chrome
  • Mozilla Firefox
  • Safari
  • Microsoft Edge

Customization

You can modify the styles.css file to change:

  • Color schemes
  • Font families
  • Layout dimensions
  • Button styles

License

MIT License - see the LICENSE file for details.

Acknowledgements

This project was built as part of my learning journey with freeCodeCamp. The requirements and concept are based on their JavaScript Algorithms and Data Structures certification.

About

Simple web app that validates US phone numbers. Checks if a given number follows valid US formatting patterns including country code, parentheses, spaces, and dashes. Built with HTML, CSS, and JavaScript. Live demo included.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors