Question: (checkpostalcode.html) Write a function named isValidPostalCode that returns true if a given Canadian postal code is valid, otherwise it returns false. A valid postal code

(checkpostalcode.html) Write a function named isValidPostalCode that returns true if a given Canadian postal code is valid, otherwise it returns false. A valid postal code is in the format of LDL DLD, here I means a letter (uppercase or lowercase) and D means a digit. A valid code may contain spaces at the beginning or at the ending, and may or may not contain a single space in the middle. Create another function named checkPostalCode that reads the postal code entered in the input textbox, and replaces all the spaces in the code by using the String's replace method in the following way: replace(" ", "I'). You can also convert all the letters to uppercases by calling the toUpperCase() method. The function checkPostalCode then calls the function is ValidPostalCode to check whether the code from the user is valid. If not, display an appropriate message in an alert box, else display the message "Thank you for entering the postal code.", and if the user did not enter a space in the middle, insert a space there and update the code in the input textbox. The function checkPostalCode is called when the button is clicked
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
