MWD1001 Website Production Using JavaScript with Forms.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
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.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
MSc. Publishing on WWW JavaScript. What is JavaScript? A scripting language devised by Netscape Adds functionality to web pages by: Embedding code into.
Tutorial 6 Working with Web Forms
Web Page Behavior IS 373—Web Standards Todd Will.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Introduction to JavaScript Form Verification - Fort Collins, CO Copyright © XTR Systems, LLC Verifying Submitted Form Data with JavaScript Instructor:
Course Textbook: Build Your Own ASP.Net Website: Chapter 2
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
Client-Side programming with JavaScript 3
Javascript and the Web Whys and Hows of Javascript.
JavaScript Form Validation
Department of Information Technology e-Michigan Web Development 0 HTML Form Creation in the Vignette Content Management Application.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
INE1020 Introduction to Internet Engineering Tutorial 8 All about Lab 6.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
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.
G053 - Lecture 16 Validating Forms Mr C Johnston ICT Teacher
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Website Development with PHP and MySQL Saving Data.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
JavaScript - A Web Script Language Fred Durao
PHP Form Introduction Getting User Information Text Input.
Web Development 101 Presented by John Valance
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
 Computer use language to communicate  A web browser will read these tags and translate it into what you actually see  Viewing Code of ESPN WebsiteESPN.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
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.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
HTML5 and CSS3 Illustrated Unit C: Getting Started with CSS.
G046 – Lecture 2A Recognising Web-Technologies Mr C Johnston ICT Teacher
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Section 10.1 Define scripting
JavaScript, Sixth Edition
Getting Started with CSS
Section 17.1 Section 17.2 Add an audio file using HTML
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Web Programming– UFCFB Lecture 17
Web Design and Development
Tutorial 10: Programming with javascript
Presentation transcript:

MWD1001 Website Production Using JavaScript with Forms

MWD1001 Website Production Topics  JavaScript Basics  JavaScript and Forms  Dreamweaver Implementation  Custom Functions

MWD1001 Website Production Basics  JavaScript is an interpreted language which follows C-style syntax  Code can be embedded in web pages or linked from other files  Object-Oriented style – usually event-driven –Mouse over and mouse click events –Form submissions –Page Opening events

MWD1001 Website Production Careful!  JavaScript is not Java!  Variables are not typed –Always check user inputs  Code can be seen by visitors to web page  Browser compatibility issues

MWD1001 Website Production Implementation

MWD1001 Website Production Adding JavaScript to pages  JavaScript code goes in tags: 

MWD1001 Website Production Locations  Typically add code to the of the web page  Can also use separate file:  Tend to use functions to contain JavaScript code  Need a mechanism to call the functions

MWD1001 Website Production Calling functions  HTML tags can trigger JavaScript events:   Different events are valid for different tags – a longer list is on Moodle

MWD1001 Website Production Web Forms

MWD1001 Website Production Validation  Common use of JavaScript is to ensure required fields of a form have been filled in  Can go further and insist field contents follow set pattern – eg Post Code or address  Test the contents of specified form fields to verify their contents

MWD1001 Website Production Implementation  Use the onSubmit parameter of a form tag to trigger JavaScript event  Call a function to validate form and return either true or false  e.g. <form onSubmit="return validate( )"...  Browser will only submit form when a return value of true received

MWD1001 Website Production Variable Names  Important to give each form a unique name parameter –Assume a form called addrForm –Assume textbox called firstName  Can refer to value typed into the first name text box as: –document.addrForm.firstName.value

MWD1001 Website Production Sample check  Function checkForm( ) { first = document.addrForm.firstName.value;  if ((first == null) || (first == "")) then { alert("Please enter first name"); return false; }  return true; }

MWD1001 Website Production Further Checks  May want to check other field more closely – address must sign  Use JavaScript built-in indexOf() function  Returns position character in string or - 1 if not found  if < 0) then {

MWD1001 Website Production Basic validation  Build a series of If statements to check whether fields are missing or invalid  Return false if a field is missing  Have a final return true if all tests passed

MWD1001 Website Production Other form fields  Radio buttons and check boxes will have a value if selected and null if not  dropdowns are more complex  Treated as an array – so we need an array index  s = document.frm.selectBox; val = s.options[s.selectedIndex].value;  Rarely need to validate drop-down menus

MWD1001 Website Production Using Dreamweaver

MWD1001 Website Production Canned JavaScript  Dreamweaver allows you to add built-in JavaScript functions to your pages –Click on a form –Open the behaviors tab –Click on the + –Pick Validate Form –Choose the fields you need

MWD1001 Website Production Dreamweaver Functions  The canned functions in Dreamweaver are generic  In many cases they are good enough  Code is much more involved than the simple examples you have seen so far  May find the error messages are not friendly enough

MWD1001 Website Production Custom Functions

MWD1001 Website Production Patterns in Data Fields  What is a valid address?  What is a valid UK postcode?  What is a valid credit card number?  Can obtain JavaScript functions from the Internet to validate these data types

MWD1001 Website Production Validating Credit Cards  Credit card numbers are generated according to a mathematical algorithm  Can be checked for validity using the Luhn algorithm –Starting from the right-hand side – double the second (and alternate) digits –If number > 10, add two digits together –Add all numbers (doubled and not) together –Should be a multiple of 10