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 into one page page DepositCalculator.php When accessed, this php
page represents the user a web form as below:
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 and
Postal code must be in the form of XnX nXn where X is an upper or lowercase
letter and n is a digit from to with or without space between the first characters
and the last characters.
Phone number must be in the form of nnnnnnnnnn where n is a digit, the first n in
the first and the second digit groups cannot be or
Email must be in the form of aaa@xxxyyy where aaa and xxx is a character
including dot string of any length, yyy is a to 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 reenter 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
If all fields are valid, the page will present the result of calculation as below:
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
