AnukramaPoudyal / Dine-In-System

0 stars 0 forks source link

Phone Number Field Accepts Less Than 10 Digits in "Book Table" Form #20

Closed nis-matina closed 6 months ago

nis-matina commented 6 months ago

@AnukramaPoudyal I would like you to solve this bug in our system. Description: The "Book Table" form allows users to enter a phone number with fewer than 10 digits. This is incorrect as phone numbers should have exactly 10 digits to ensure valid entries and proper communication.

Steps to Reproduce: Navigate to the "Book Table" form. Enter a phone number with fewer than 10 digits in the phone number field. Submit the form. Observe that the form is accepted and processed despite the invalid phone number entry.

Expected Behavior: The phone number field should only accept entries that are exactly 10 digits long. If a user attempts to enter fewer than 10 digits, an error message should be displayed, preventing form submission until the correct number of digits is entered.

Actual Behavior: The form accepts phone numbers with fewer than 10 digits and proceeds with the submission process, which can lead to invalid contact information being stored and potential communication issues.

AnukramaPoudyal commented 6 months ago

To address the issue with the "Book Table" form, I focused on implementing phone number validation to ensure entries contain exactly 10 digits. First, I modified the findTable() function to include a validation step for the phone number field. After retrieving the phone number value from the form, I added a condition to check if the length of the phone number is not equal to 10 or if it contains non-numeric characters. If either condition is true, an alert message is displayed prompting the user to enter a valid 10-digit phone number, and the form submission is prevented.

By incorporating this validation logic into the function, the "Book Table" form now accurately verifies the phone number input, ensuring that only entries with exactly 10 digits are accepted. This prevents the submission of invalid contact information and helps avoid potential communication issues in the reservation process.

Code proof:

// Validate phone number if (phoneNumber.length !== 10 || isNaN(phoneNumber)) { alert("Please enter a valid 10-digit phone number."); return false; }