IS1500: Introduction to Web Development

Slides:



Advertisements
Similar presentations
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Advertisements

Ch3: Introduction to HTML5 part 2 Dr. Abdullah Almutairi ISC 340 Fall 2014.
Form Validation. Learning Objectives By the end of this lecture, you should be able to: – Describe what is meant by ‘form validation’ – Understand why.
1 Topic 6 Processing Form Input. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction Form.
Tutorial 14 Working with Forms and Regular Expressions.
Lesson 8 Creating Forms with JavaScript
CST JavaScript Validating Form Data with JavaScript.
Client-Side programming with JavaScript 3
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
JavaScript Form Validation
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Module 7: Validating User Input.
.NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
What is Validation Understanding Validation (Different from Verification)
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
Introduction to Client-Side Web Development Introduction to Client-Side programming using JavaScript JavaScript; application examples 10 th February 2005.
AS computing Validation and verification. Introduction It is important to maintain the integrity of any database of information. Any data item must always.
VALIDATION CONTROLS.  Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt.
Introduction to JavaScript CS101 Introduction to Computing.
Verification & Validation. Batch processing In a batch processing system, documents such as sales orders are collected into batches of typically 50 documents.
1 AQA ICT AS Level © Nelson Thornes 2008 Good quality data and information Data terms.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 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.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
HTML FORMS The TEXT Object Presented By: Ankit Gupta.
CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
>> Form Data Validation in JavaScript
JavaScript.
JavaScript, Sixth Edition
Chapter 5 Validating Form Data with JavaScript
CS 330 Class 7 Comments on Exam Programming plan for today:
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
IS1500: Introduction to Web Development
PHP Hypertext Preprocessor
Section 17.1 Section 17.2 Add an audio file using HTML
Introduction to JavaScript
Validation Bury College.
Web Programming– UFCFB Lecture 17
Working with Forms and Regular Expressions
MIS Professor Sandvig MIS 324 Professor Sandvig
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Conditions and Ifs BIS1523 – Lecture 8.
Lesson 5: Epic Appointment Scheduling Referrals
Chapter 6 Event-Driven Pages
JavaScript Form Validation
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
Lesson 5: Epic Appointment Scheduling Referrals
Lesson 5: Epic Appointment Scheduling Referrals
Web Development & Design Foundations with H T M L 5
Chapter 7: Input Validation
Introduction to JavaScript
.NET Validation Controls
Web Development & Design Foundations with HTML5 7th Edition
Presentation transcript:

IS1500: Introduction to Web Development JavaScript: Form Validation & Exceptions Martin Schedlbauer, Ph.D. m.schedlbauer@neu.edu

JavaScript: Client-Side Forms Client-Side Scripting with JavaScript Validating FORM Input IS1500 JavaScript: Client-Side Forms

JavaScript: Client-Side Forms Validating Forms The content of form elements should generally be validated via a JavaScript function to ensure that it contains the expected input. For example: Does a text field really contain a number or does it contain text? Is the date valid? Does the credit card number has 15 or 16 digits? Does a mandatory field contain input or has it been left empty? Is the input in the expected range? IS1500 JavaScript: Client-Side Forms

Client-Side Validation Take this scenario: You are asking for a zip code as part of an address entry form. The user types in 021156 or Boston, MA – clearly both are wrong zip codes. If you don’t check the validity of the zip code format then you would send incorrect data to the server where it must be checked and then an error page would need to be returned. That adds a lot of extra processing time. It would be much better to check if the field contains the correctly formatted data. For example, check that the field contains exactly five digits. If it doesn’t then display an error on the client and don’t submit the form to the server for processing. IS1500 JavaScript: Client-Side Forms

JavaScript: Client-Side Forms Client-Side Scripting with JavaScript Validation Patterns IS1500 JavaScript: Client-Side Forms

Pattern: No Empty Field This example shows how to ensure that a field contains a value. It checks if the field contents is empty (""). Name: <input type="text" id="name" /> <p /> <button onClick="processForm()">Calculate</button> <script> function processForm() { // retrieve form entries var name = document.getElementById("name").value; if (name == "") // check if name is empty alert("Name cannot be empty!"); return; // stop processing; exit the function } // end if } // end processForm </script> IS1500 JavaScript: Client-Side Forms

Pattern: Number-Only Field This example shows how to ensure that a field contains a number. It checks if the field is not “not a number” using isNaN(). Name: <input type="text" id="number" /> <p /> <button onClick="processForm()">Calculate</button> <script> function processForm() { // retrieve form entries var num = document.getElementById("number").value; if (isNaN(num) == true) // check if num is not a number alert("Must be a number, no letters or characters allowed!"); return; // stop processing; exit the function } // end if } // end processForm </script> IS1500 JavaScript: Client-Side Forms

Stopping a Function with return When a function reaches a point where continuing is not reasonable because it does not have the correct input values, it must “return”. The return statement exits the function immediately. No code after the return is executed. IS1500 JavaScript: Client-Side Forms

Summary, Review, & Questions… IS1500 JavaScript: Client-Side Forms

JavaScript: Client-Side Forms Name: <input type="text" id="name" /> <p /> <button onClick="processForm()">Calculate</button> <script> function processForm() { // retrieve form entries var name = document.getElementById("name").value; alert("in processForm: 2 - " + name); if (name == "") // check if name is empty alert("Name cannot be empty!"); return; //stop processing; exit the function } // end if } // end processForm </script> IS1500 JavaScript: Client-Side Forms