1 JavaScript 4 User Input Validation. 2 Input Validation One of the most useful applications of JavaScript is input validation Scripts in the page can.

Slides:



Advertisements
Similar presentations
Collecting data Chapter 6. What is data? Data is raw facts and figures. In order to process data it has to be collected. The method of collecting data.
Advertisements

Chapter 16: Check Digit Systems, Continued
Math for Liberal Studies. An identification number is a sequence of letters and/or numbers that identifies an object, person, place, or concept The number.
23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
24-Aug-14 HTML Forms. 2 What are forms? is just another kind of HTML tag HTML forms are used to create (rather primitive) GUIs on Web pages Usually the.
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Math for Liberal Studies.  None of the methods we have investigated so far can detect transposition errors  In this section we will investigate new.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Tutorial 14 Working with Forms and Regular Expressions.
MAT 1000 Mathematics in Today's World Winter 2015.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Validation and Verification Today will look at: The difference between accuracy and validity Explaining sources of errors and how they could be overcome.
Ngiam Shih Tung December 22, 2003 Fun with numbers Breaking the NRIC check digit algorithm.
Barcodes and ISBN numbers: which are better at detecting errors? Virtually all packaged products have a barcode on so that optical readers can recognise.
More to Learn Check digit –It is used to check whether a number is valid. –Both ISBN and Hong Kong Identity Card numbers contain a check digit for data.
© All Rights Reserved Barcodes How does a barcode reader work?
Validation and Verification
Method for verifying a credit card number: Example:
RNJ 10/02/091 3 Computing System Fundamentals 3.6 Errors Prevention and Detection.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
 By the end of this, you should be able to state the difference between DATE and INFORMAITON.
Tutorial 14 Working with Forms and Regular Expressions.
WML II (“Son of WML”) WML WMLScript. WML - A Quick Review Document structure ,... Text and image controls ...,,..., Navigation controls ,,, Events.
Wong Wai Ling, Lam Pui Ki Identification number  clearly identify a person or a thing Check digit  an extra digit for the purpose of error.
Encoding, Validation and Verification Chapter 1. Introduction This presentation covers the following: – Data encoding – Data validation – Data verification.
Fault Tolerance CDA 5140 Spring 06 Everyday FT. Background Use of check digits for error detection on everyday applications used extensively but most.
Lecture 12.  The ISBN 10-digit uses a reverse weighting system: multiply the first digit by 10, the second by 9, the third by 8 and so on until the check.
Checking data Chapter 7 Prepared by:Sir Mazhar Javed.
Objectives of Control The objectives of control are:  To ensure that all data are processed  To preserve the integrity of maintained data  To detect,
System Development Lifecycle Verification and Validation.
Error Control Code. Widely used in many areas, like communications, DVD, data storage… In communications, because of noise, you can never be sure that.
Data and information. Information and data By the end of this, you should be able to state the difference between DATE and INFORMAITON.
AS computing Validation and verification. Introduction It is important to maintain the integrity of any database of information. Any data item must always.
MAT 105 Spring  An identification number is a sequence of letters and/or numbers that identifies an object, person, place, or concept  The number.
DATA ERRORS. Introduction The processing of incorrect data can produce ridiculous and embarrassing output. Errors can take time to sort out and can be.
ITGS Databases.
Verification & Validation. Batch processing In a batch processing system, documents such as sales orders are collected into batches of typically 50 documents.
Review of Data Capture. Input Devices What input devices are suitable for data entry? Keyboard Voice Bar Code MICR OMR Smart Cards / Magnetic Stripe cards.
1 3 Computing System Fundamentals 3.6 Errors Prevention and Recovery.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Data Verification and Validation
1 AQA ICT AS Level © Nelson Thornes 2008 Good quality data and information Data terms.
Math for Liberal Studies. What is an identification number?  An identification number is a sequence of digits and/or numbers that identifies an object,
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Posting Journal Entries to General Ledger Accounts
Software. Because databases can get very big, it is important to decide exactly what is going to be stored in each field. Fields can be text, number,
Data Transmission and Networks Transmission error checking & correcting.
Input, Output and Processing.. What data needs to be input into the system? Identify the sources – i.e. where does the data come from? What is the volume.
Data Capture Forms What are they?. Example 1 Example 2.
DATA TYPES.
IS1500: Introduction to Web Development
Donation form optimisation Glyn Thomas
Analyzing Numerical Data: Validating Identification Numbers
Uses Uses of cryptography Lab today on RSA
Validation Bury College.

Working with Forms and Regular Expressions
Keeper 8: UPC Codes S.A.S. #12 1 – 3 Credit Cards S.A.S. #
Chapter 16: Introduction
Credit Cards UPC Codes.
Objectives TO UNDERSTAND THAT CAPTURING DATA IS VALIDATED AND VERIFIED TO CHECK THAT IT IS REASONABLE AND CORRECT.
Fundamentals of Data Representation
How Credit Card Numbers are Generated

Chapter 16: Check Digit Systems, Continued
Method for verifying a credit card number:
Introduction to Databases
Unit 3: Variables in Java
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Testing & Security Dr. X.
Presentation transcript:

1 JavaScript 4 User Input Validation

2 Input Validation One of the most useful applications of JavaScript is input validation Scripts in the page can check that inputs conform to particular formats before sending them to the server This can make for a better user experience, save time and other resources Validator checks format User enters data Server processes it input ok not ok "oops!"

3 Rep. Ireland Mobile Numbers /5/6/7 + 7 digits Irish mobiles start with 08 followed by either 3, 5, 6, 7 (088 is obsolete now), followed by 7 digits

4 var mobilenum; var valid = new Boolean(true); mobilenum =prompt("Please enter your mobile phone number", " "); if ((mobilenum==null) || (mobilenum=="")) valid= false; if (mobilenum.length != 10) valid=false; if (mobilenum.slice(0,2) != "08") valid=false; var c = mobilenum.slice(2,3); if (! ((c=="3") || (c=="5") || (c=="6") || (c=="7")) ) valid=false; for (n=3;n<10;n++) { c = mobilenum.slice(n,n+1); if ((c "9")) valid=false; }

5 Checksum Very often 1 digit of an input is used to detect errors Imagine if the last digit of a phone number was required to be the number of even digits If someone made a mistake it might be detected if the numbers didn’t add up something's wrong! Checksums are not usually so simple and typically applying a multiplier to some of the digits

6 Credit Card Numbers The last digit of a 16- digit credit card number is a check sum It doesn't tell you if the number is valid, or the account has enough money But if the checksum is wrong it can't be correct

7 Luhn Formula for Credit Cards Starting with the second last digit of the number, multiply every second digit by 2 Add all the resulting digits, together with the unmodified digits, and the check sum If the resulting number is evenly divisible by 10 then the checksum is valid

= mod 10 = 0 so checksum is valid Luhn Formula for Credit Cards

9 CardPrefixLength Visa413 / 16 American Express 34 / 3715 MasterCard Discover Diners Club / 36 / 3814

10 Every book has a unique number that identifies the publisher and other information The last digit of the ISBN is a MOD 11 checksum International Standard Book Number ISBN

11 ISBN x MOD 11 = 0 so it's valid

12 ISBN X x MOD 11 = 0 so it's valid Note that MOD 11 can result in 10. So the last digit may be X = 10. (Roman numbers live!)

13 Modulus Checksums In general the modulus chosen needs to be –Greater than the number digits –Greater than the range of any single digit Prime numbers work especially well Random ISBN errors have 90% (10/11) chance of being caught.

14 R. Ireland PPS Numbers Every person working in the Republic of Ireland has a PPS number Children are now issued them at birth Organizations that may request and store them are specifically controlled by legislation The number is 7 digits followed by a checksum letter

15 PPSN H x Total = MOD 23 = 8 = H ABCDEFGHIJKLMNOPQRSTUVW Some woman in Ireland have PPS numbers identical to their husband's, but followed by a W. So there may be 2 letters - a check sum and a W. It is co-incidence that W is the 23rd letter. This W is for "wife". This somewhat sexist practice has been discontinued.

16 X Convert first letter to a number (A=1, B=2, … Z=26) Add up all the digits =71 Add those together (as often as required) 7+1 = 8 Final result will always be 8 Euro banknote serial numbers

17 Finland's Sosiaaliturvatunnus or SOTU DDMMYYSPPPC DDMMYY - date S is separator –+ for people born in 1800's –- for people born in 1900's –A for people born in 2000's PPP is a person number. Even for females an odd for males This means that at most 500 men can be born in Finland is any 1 day! (currently <100) C is checksum Treat DDMMYYPPP as a large number and MOD by 31 MOD is mapped to a single character from ABCDEFHJK LMNPRSTUVWXY So if MOD 31 is 15 checksum is E You are not expected to know this for exam purposes

18 Exercises Test ISBNs and random 10 digit numbers with the ISBN checksum Verify your PPSN checksum Verify your credit card checksum Write JavaScript code to validate ISBNs and PPSNs

19 Other Examples P.R. China (mod 11), UK, Italy (mod 26) all use checksums The U.S. and Canada share a numbering system, but only Canadian numbers use a checksum Many barcode systems use a checksum too R. Ireland CAO student numbers use a checksum but the method used is a secret