Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 L 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

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

2. How will the team select a leader?

Answered: 1 week ago