Web-based Application Development Lecture 19 March 23, 2006 Anita Raja.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Benchmark Series Microsoft Access 2010 Level 1
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
1 JavaScript: Control Structures II. 2 whileCounter.html 1 2
Chapter 07: Lecture Notes (CSIT 104) 1111 Exploring Microsoft Office Excel 2007 Chapter 7 Data Consolidation, Links, and Formula Auditing.
Excel Chapter 6 Review slides. How many worksheets are in a workbook, by default? three.
Programming Logic and Design Sixth Edition
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Tools for Text Review. Algorithms The heart of computer science Definition: A finite sequence of instructions with the properties that –Each instruction.
3.1 Data and Information –The rapid development of technology exposes us to a lot of facts and figures every day. –Some of these facts are not very meaningful.
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
Web-based Application Development Lecture 20 April 4, 2006 Anita Raja.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Announcements The first graded lab will be posted Sunday 2/15 and due Friday 2/27 at midnight It is brand new, so please don’t hand in last semester’s.
Comparing Numeric Values If Val(Text1.Text) = MaxPrice Then (Is the current numeric value stored in the Text property of Text1 equal to the value stored.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Web-based Application Development Lecture 18 March 21, 2006 Anita Raja.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
CST JavaScript Validating Form Data with JavaScript.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Basic Navigation in SAP For the Windows Graphical User Interface (GUI) Click your mouse anywhere or select “Page Down” to scroll through the pages.
Tutorial 14 Working with Forms and Regular Expressions.
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.
JavaScript, Fourth Edition
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
07/10/ Strings ASCII& Processing Strings with the Functions - Locate (Instr), Mid, Length (Len), Char (ChrW) & ASCII (Asc)
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Flow of Control Part 1: Selection
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Basic Data Types Characters vs. Numbers Adding in Binary: There are only.
Introduction to Database using Microsoft Access 2013 Part 6.1 November 18, 2014.
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
Chapter Three The UNIX Editors.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript, Fourth Edition
© Oxford University Press All rights reserved. CHAPTER 6 STRINGS.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Data Management Data Verification Data Validation.
Copy of the from the secure website - click on the AccoridaLife.zip link.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
1 CA202 Spreadsheet Application Focusing on Specific Data using Filters Lecture # 5.
Computer Programming 2 Lab (1) I.Fatimah Alzahrani.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
DCT1063 Programming 2 CHAPTER 3 STRINGS Mohd Nazri Bin Ibrahim Faculty of Computer, Media & Technology TATi University College
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays.
JavaScript, Sixth Edition
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
The purpose of a CPU is to process data Custom written software is created for a user to meet exact purpose Off the shelf software is developed by a software.
LINGO TUTORIAL.
DATA TYPES.
Programming the Web using XHTML and JavaScript
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
T. Jumana Abu Shmais – AOU - Riyadh
Looping III (do … while statement)
Loops.
Programming Logic and Design Fifth Edition, Comprehensive
Introduction to Computer Science
Presentation transcript:

Web-based Application Development Lecture 19 March 23, 2006 Anita Raja

Frameset document Linking between frames TableOfContents.htm document Table of Contents: Click here to view document 1 in the bottom right frame Click here to view document 2 in the bottom left frame

Reminders Some final project pointers Mar 30 and April 4 2 demo volunteers each No class Mar 28 th Mar 30 th Lab Session Woodward 335

Programming the Web using XHTML and JavaScript Chapter 15 Strings, Dates, and Cookies

Validation vs. Verification Valid – meets certain criteria For example, a purely numeric value Or a text value not more than seven characters in length Verified – represents the truth The User ID matches a value in the list of actual IDs The password is the correct password for a given User ID

Validation vs. Verification Verification is hard to accomplish with JavaScript Why? Because the data and program have to reside on the user’s computer That is, the list of passwords would have to be downloaded to the user’s PC

Validation vs. Verification Validation can be accomplished easily in JavaScript Assume an input screen that requests: Name Student Identification Number (SID) Rules: Exactly eight digits Numerals only (no alphabetical characters)

Validation vs. Verification To validate the SID we must check to see: That the entry is exactly eight digits in length Each digit is in the range 0 to 9 only Remember, data input via a text box appears to JavaScript as a string String variables are actually string objects

Validation vs. Verification String objects possess: 30 methods, for example Search within the string for a substring Change the case Replace one character with another One property: length (the number of characters in the string)

Validation vs. Verification Assume the form looks like this … Ch15-Script-01

Validation vs. Verification Then the value stored in the SID text box is referred to as: document.surferInfo.SIDBox.value This is a string object so its length is referred to as: document.surferInfo.SIDBox.value.length And we can validate its length with a conditional statement like this … Ch15-Script-02

Validation vs. Verification How can we check the individual string characters? String objects include a substring method Syntax (JavaScript) is substring(n,m) Starting character position Ending character position plus one

Validation vs. Verification Thus, var myName=“Mary” var char1=myName.substring(0,1) would result in char1 containing “a” Also, var myName=“Mary” var char1=myName.substring(2,4) would result in char1 containing “ry”

Validation vs. Verification In substring(n,m), the number of characters that are being referred to is: m – n So, substring(2,4) refers to 2 (4-2=2) characters, the 3 rd and 4 th in the string

Validation vs. Verification There is also a single character extraction function charAt(n) That extracts the nth character: var myName=“Mary” var char1=myName.charAt(1) would result in char1 containing “a” Note that “extract” really means “copy”

Validation vs. Verification Collating sequence Computers represent everything as a numeric value Thus, every keyboard symbol has a value The ASCII code (used in PCs) defines the values for all symbols

ASCII Codes

Validation vs. Verification Since every symbol has a value, a hierarchy can be established Thus, “A” is “less than” “B” because the ASCII code for an A, 65, is less than the ASCII code for a B, 66. We can use these relationships to see if a character in a string falls within a given range

Validation vs. Verification To validate the SID, we want to: Extract a single character Check to see that it’s a value in the numeric digit range (decimal values 48 – 57) Repeat until all characters have been checked

Validation vs. Verification theChar=document.surferInfo.SIDBox.value.substring(0,1) if (theChar ”9“) alert(“Invalid SID”) Really means If (the ASCII value of the character is less than 48 or the ASCII value of the character greater than 57) alert(“Invalid SID”)

Validation vs. Verification Now we have to repeat this process for each character in SIDBox: for () { theChar=document.surferInfo.SIDBox.value.substring(0,1) if (theChar ”9“) alert(“Invalid SID”) }

Validation vs. Verification Now we have to repeat this process for each character in SIDBox: for (i=0; i<=7; i++) { theChar=document.surferInfo.SIDBox.value.substring(0,1) if (theChar ”9“) alert(“Invalid SID”) }

Validation vs. Verification Need some way to control the loop and refer to subsequent characters in the substring: for (i=0; i<=7; i++) { theChar=document.surferInfo.SIDBox.value.substring(i,i+1) if (theChar ”9“) alert(“Invalid SID”) } Ch15-Script-03

Validation vs. Verification Once we know the SID is invalid there’s no point in continuing the loop (Unless we want to point out each invalid character individually) So, how to we stop a loop before it’s finished? With a break statement

Validation vs. Verification When JavaScript encounters break it acts like the continuing condition of the loop is false and immediately exits the loop Ch15-Script-04

Date Objects JavaScript accesses the computers date and time via a Date object Create a new one by: var timeandDate = new Date() Date objects include a number of methods

Date Objects MethodMeaningUnits getFullYear()4-digit year2000, 2001, etc. getMonth()Month no.0-11 getDate()Day of month 1-31 getDay()Day of week0-6 getHours()Hour no.0-23 getMinutes()Minute no.0-59 getSeconds()Second no.0-59

Date Objects We can use Date objects to display the current date and time Ch15-Script-05