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

 3. [17 marks] (checkpostalcode.html) Write a function named isValidPostalCode that returns

3. [17 marks] (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("",""). You can also convert all the letters to uppercases by calling the toUpperCase() method. The function checkPostalCode then calls the function isValidPostalCode 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

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 Databases Questions!