Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I've been asked to validate the booking reference of an App. here is the task: Although the client-side validation checks the correct form of the

I've been asked to validate the booking reference of an App. here is the task: Although the client-side validation checks the correct form of the booking reference, it does not actually check it is a valid booking reference. For a reference to be valid, the server-side should validate the reference to the same format as the client-side, plus the following additional constraints: the three-letter group must be one of "ABC", "ACD", "BCD". Anything else is invalid. The next character must be a hyphen. Anything else is invalid. The first digit may only be 5 or 8. The other digits may be any value between 0 and 9 inclusive. You need to provide checks and only if all are valid, proceed to write the data to the database. If not, provide feedback to the user that the booking reference is invalid. Add a comment to your validation code explaining the meaning of each part of your booking reference validation expression. Again, examine the existing code closely, it will guide you. The easiest way to test regular expressions is using a free online tool - search the web for 'regex tester' to discover these. my code doesn't work and I don't know why:

$value = $data['bookingref'];

// ^ = anchor, [ABCACDBCD] = one of the three-letter group, - = hyphen, [58] = first digit, [0-9] = other digits

$format = "/^[ABCACDBCD]-[58][0-9]{5}$/";

// If value does NOT match the format then it is invalid

if (!preg_match($format, $value)) {

$feedback['bookingref'] = 'Server feedback: Invalid booking reference format';

$valid = false;

}

The hyphen doens't work at all. When I go on admin.js here is what I did. Probably there's something wrong with that too? .

if (inputElement.id == "bookingref") {

// ^$ = anchors, [a-zA-Z0-9] = letters/digits/spaces, \-= one - symbol, * = 0 or more characters

pattern = /^[a-zA-Z0-9 ]*$/, /^.+\-.+$/; feedback = "Only letters, numbers and hypen are permitted"; Here's what it shows when I try to insert the ref number. image text in transcribed

Server feedback: Invalid booking reference format

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago