Strings Robin Burke IT 130. Outline Objects Strings methods properties Basic methods Form validation.

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

MWD1001 Website Production Using JavaScript with Forms.
Programming Paradigms and languages
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
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.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Information Technology Center Hany Abdelwahab Computer Specialist.
25-Jun-15 JavaScript Language Fundamentals II. 2 Exception handling, I Exception handling in JavaScript is almost the same as in Java throw expression.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Tutorial 14 Working with Forms and Regular Expressions.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Introduction to JavaScript Form Verification - Fort Collins, CO Copyright © XTR Systems, LLC Verifying Submitted Form Data with JavaScript Instructor:
MIT AITI 2003 Lecture 7 Class and Object - Part I.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
CST JavaScript Validating Form Data with JavaScript.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JavaScript Form Validation
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Tutorial 14 Working with Forms and Regular Expressions.
Scripting Languages.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Faculty of Sciences and Social Sciences HOPE JavaScript Validation Regular Expression Stewart Blakeway FML
Generations of Programming Languages First generation  Machine Language Second Generation  Assembly Language Third Generation  Procedural language such.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
Chapter 3 : Processing on the Front End JavaScript Technically its name is ECMA-262, which refers to the international standard which defines it. The standard.
JavaScript Lecture 6 Rachel A Ober
CC1003N Week 6 More CSS and Javascript.. Objectives: ● More CSS Examples ● Javascript – introduction ● Uses of Javascript ● Variables ● Comments ● Control.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Chapter 8 Cookies And Security JavaScript, Third Edition.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Fall Week 4 CSCI-141 Scott C. Johnson.  Computers can process text as well as numbers ◦ Example: a news agency might want to find all the articles.
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 15 JavaScript.
XP Tutorial 8 Adding Interactivity with ActionScript.
The Web Wizard’s Guide To JavaScript Chapter 3 Working with Forms.
Working With Objects Tonga Institute of Higher Education.
Loops Robin Burke IT 130. Outline Announcement: Homework #6 Conditionals (review) Iteration while loop while with counter for loops.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
ASSIGNMENT POINTS DUE DATE: Monday NOV 30 JAVASCRIPT, INPUT VALIDATION, REGEX See 2 nd slide for Form See 3 rd next slide for the required features.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
JavaScript, Sixth Edition
Expressions and Data Types Professor Robin Burke.
OVERVIEW OF CLIENT-SIDE SCRIPTING
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 15 JavaScript.
Chapter 5 Validating Form Data with JavaScript
JavaScript is a programming language designed for Web pages.
Web Programming– UFCFB Lecture 17
Working with Forms and Regular Expressions
JavaScript What is JavaScript? What can JavaScript do?
M150: Data, Computing and Information
JavaScript What is JavaScript? What can JavaScript do?
JavaScript Basics What is JavaScript?
Introduction to Computer Science
Web Programming and Design
Presentation transcript:

Strings Robin Burke IT 130

Outline Objects Strings methods properties Basic methods Form validation

Objects So far our expressions values operations functions Examples "a" + "b" 10 / 3 alert ("help!")

Objects cont'd What about document.write (...)? arr.length? Math.sqrt() What does this dot notation mean? signals the use of objects

Objects cont'd Object a bundle combining data and computation Example traffic light could be represented by a state variable state: "green"

Object operations We could write a function function changeLight (light) { if (light == "green") return "yellow"; else if (light == "red") return "green"; else return "red"; } We could use it as follows var trafficLight = "green"; trafficLight = changeLight (trafficLight);

OK but What happens when we elaborate our model flashing red flashing yellow left turn signal What if somebody violates our design trafficLight = "blue"; What happens if we want to export our program to Mexico trafficLight = "rojo"; We want to link traffic lights in intersections

Objects Help make code easier to maintain make code easier to adapt make programs of increasing size and complexity possible The idea combine data and operations together

Traffic Light Property state linked Methods change () flash (color)

Object syntax Objects are created with new assign to a variable var tl = new TrafficLight ("green"); Properties and methods use variable name dot property or variable name dot method call tl.state tl.change() tl.flash("yellow")

Using objects We can write var northbound = new TrafficLight ("green"); var southbound = new TrafficLight ("green"); var eastbound = new TrafficLight ("red"); northbound.change(); southbound.change(); delay (); northbound.change(); southbound.change(); eastbound.change();

Benefits Data is encapsulated in the object more elaborate notion of state? turn signal just add more state variables turnSignalState Code that modifies the state data is associated directly with it Whole package is created at once easy to make many instances

Object-oriented programming Most significant advance in programming since high-level languages made in the 1980s All major languages are now object-oriented C++ C# Java JavaScript Visual Basic

OOP cont'd Object-oriented programming is largely about defining new objects that interact computationally in an application linked to each other Example A PowerPoint presentation object contains slide objects each slide object  contains text objects  contains graphic objects

OOP cont'd Beyond the scope of this class CSC 211/212 etc. We need to know how to use the objects JavaScript provides

Arrays Arrays (in JavaScript) are objects, too Constructed with new Property length Methods special syntax with [ ]

Strings Objects Special constructor not new quotes var str = "foo"; legal but unnecessary var str = new String ("foo"); Properties length like array

Some methods toUpperCase( ) converts string to upper case toLowerCase( ) converts string to lower case charAt(pos) returns character at given position substring(start, end) returns a string out of the middle

Example string.html

Note Different calling syntax for Capitalize not part of the string object string is already part of the language can't add new methods

Architecture

Form validation Problem detecting erroneous input round-trip to server too slow HTML controls limited Solution use JavaScript to detect bad input get user to correct before hitting the server Note an efficiency tool not a data quality guarantee server must validate the data again too easy to generate a rogue request

Technique Use onSubmit event always a button to submit form data to server Special syntax onSubmit="return fn()" if fn returns true form data sent to server if fn returns false form data not sent

Example Change of password Action check that password and retype are the same Event form submission Content needed contents of two password fields

Example password Problems? privacy prompt minimum length clear focus

Other validation criteria valid address integer ssn

What to do search a string for certain must be in an address no letters in an integer search method for string objects

String Search Uses special pattern syntax /bar/ the slash is like a quote means return the first location of a substring beginning with these three characters Also /[bar]/ different meaning first location of any one of these characters Not found return -1 not a legal string index

Validation with search

String Processing Many applications require editing of strings removing spaces and punctuation removing special characters Combine search with loops

Basic Idea while (pattern is still in string) copy useful bits search for pattern again

Example remove dashes from credit card # four ways to accomplish character by character repeated search whole string repeated shorter string recursion!

Monday Quiz Advanced HTML/JS stuff positioning