A simple, clean web application that validates whether a given phone number is a valid US number.
- Real-time phone number validation
- Validates US phone number formats
- Clear button to reset results
- Handles various valid formatting patterns
- User-friendly interface
- Enter a phone number in the input field
- Click the "Check" button to validate
- The application will display whether the number is valid or invalid
- Use the "Clear" button to reset the result
The validator accepts the following US phone number formats:
555-555-5555(555)555-5555(555) 555-5555555 555 555555555555551 555-555-55551 (555) 555-55551 555 555 55551 55555555551(555)555-5555
- HTML5
- CSS3
- JavaScript (Regular Expressions)
- Create a new folder on your computer
- Save the following files in that folder:
index.html(the HTML structure)styles.css(the styling)script.js(the JavaScript logic)
- Open
index.htmlin any modern web browser
telephone-number-validator/
├── index.html
├── styles.css
├── script.js
├── README.md
├── LICENSE
└── .gitignore
| 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 |
- Empty input: Shows alert message
- Valid US format: Displays "Valid US number"
- Invalid format: Displays "Invalid US number"
- Clear button: Removes result message
Works on all modern browsers including:
- Google Chrome
- Mozilla Firefox
- Safari
- Microsoft Edge
You can modify the styles.css file to change:
- Color schemes
- Font families
- Layout dimensions
- Button styles
MIT License - see the LICENSE file for details.
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.