Question: Form Validation Self posting Combine html page DepositCalculator.html and PHP page DepositCalculator.php you created in lab 2 into one page page DepositCalculator.php . When accessed,

Form Validation Self posting
Combine html page DepositCalculator.html and PHP page DepositCalculator.php you
created in lab 2 into one page page DepositCalculator.php. When accessed, this php
page represents the user a web form as below:
2. Once the user clicks the Calculate button, the web form is submitted to
DepositCalculator.php page itself. This page will then validate the data entered by the
user according to the following rules:
The user must enter data in all fields, no field can be blank.
Principal Amount must be numeric and greater than zero.
Interest Rate must be numeric and not negative.
Number of years to deposit must be a numeric between 1 and 20.
Postal code must be in the form of XnX nXn, where X is an upper- or lower-case
letter and n is a digit from 0 to 9, with or without space between the first 3 characters
and the last 3 characters.
Phone number must be in the form of nnn-nnn-nnnn where n is a digit, the first n in
the first and the second 3-digit groups cannot be 0 or 1.
Email must be in the form of aaa@xxx.yyy where aaa and xxx is a character
(including dot .) string of any length, yyy is a 2 to 4 characters string.
If the submitted form fails to pass the validation, the page displays the same web form
again with error messages next to the invalid fields as shown below:
Besides presenting the error messages, the page should have the following properties:
To improve usability, all the users previous entered values should be preserved so
that the user does have to re-enter valid values and only easily see whats wrong with
the invalid fields and revise accordingly.
When the Clear button is click, all the entered values should be cleared so that the
web form is presented in its initial state as in 1.
3. If all fields are valid, the page will present the result of calculation as below:
4. Besides satisfy the above requirements, your PHP page should define and use the
following PHP functions to validate user inputs. If the validation fails, they return the
relevant error message, otherwise, an empty string:
function ValidatePrincipal($amount){...}
function ValidateRate($amount){...}
function ValidateYears($years){...}
function ValidateName($name){...}
function ValidatePostalCode($postalCode){...}
function ValidatePhone($phone){...}
function ValidateEmail($email){...}
Form Validation Self posting Combine html page

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!