Modern JavaScript Develop And Design Instructor’s Notes Chapter 10 – Working with Forms Modern JavaScript Design And Develop Copyright © 2012 by Larry.

Slides:



Advertisements
Similar presentations
Regular Expressions BKF03 Brian Ciccolo. Agenda Definition Uses – within Aspen and beyond Matching Replacing.
Advertisements

© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● / www,histpk.org Hidaya Institute of Science & Technology
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Regular Expressions in Perl By Josue Vazquez. What are Regular Expressions? A template that either matches or doesn’t match a given string. Often called.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Copyright 2007, Information Builders. Slide 1 Implementing On-Click Functionality With the HTML Layout Painter Larry J Braun Education Specialist June,
Asp.NET Core Vaidation Controls. Slide 2 ASP.NET Validation Controls (Introduction) The ASP.NET validation controls can be used to validate data on the.
JavaScript Forms Form Validation Cookies CGI Programs.
Tutorial 14 Working with Forms and Regular Expressions.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
Tutorial 13 Working with Objects and Styles. XP Objectives Learn about objects and the document object model Reference documents objects by ID, name,
CS 174: Web Programming February 26 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Modern JavaScript Develop And Design Instructor’s Notes Chapter 2- JavaScript in Action Modern JavaScript Design And Develop Copyright © 2012 by Larry.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Introduction to JavaScript Form Verification - Fort Collins, CO Copyright © XTR Systems, LLC Verifying Submitted Form Data with JavaScript Instructor:
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Lesson 8 Creating Forms with JavaScript
REGULAR EXPRESSIONS CHAPTER 14. REGULAR EXPRESSIONS A coded pattern used to search for matching patterns in text strings Commonly used for data validation.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Last Updated March 2006 Slide 1 Regular Expressions.
JavaScript Form Validation
Regular Expressions Week 07 TCNJ Web 2 Jean Chu. Regular Expressions Regular Expressions are a powerful way to validate and format text strings that may.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Tutorial 14 Working with Forms and Regular Expressions.
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.
More Events and Validation CS Page/window events CS380 2.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 13 - Frameworks Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman.
RegExp. Regular Expression A regular expression is a certain way to describe a pattern of characters. Pattern-matching or keyword search. Regular expressions.
Using Client-Side Scripts to Enhance Web Applications 1.
1 Forms and Form elements CSD 340 McCoey. 2 Form Object Properties action Usually a call to a server elements encoding method post or get target Methods.
CS 174: Web Programming September 30 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
JavaScript and PHP Validation and Error Handling CHAPTER 17.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming regular expressions.
JavaScript, Part 2 Instructor: Charles Moen CSCI/CINF 4230.
CS346 Regular Expressions1 Pattern Matching Regular Expression.
The Web Wizard’s Guide To JavaScript Chapter 3 Working with Forms.
CSC 2720 Building Web Applications PHP PERL-Compatible Regular Expressions.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 12 – Error Management Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Looking at various Rich Message options in KRAD Kuali University: Apply Now Lab : Rich Messages Lab Objectives Understand what Rich Messages are and how.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
INT222 – Internet Fundamentals Week 11: RegExp Object and HTML5 Form Validation 1.
HTML 5 Form elements Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
USABLEANDACCESSIBLEFORMS. accessibility or Accessibility?
Modern JavaScript Develop And Design Instructor’s Notes Chapter 8 – Event Handling Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman.
Chapter 4 © 2009 by Addison Wesley Longman, Inc Pattern Matching - JavaScript provides two ways to do pattern matching: 1. Using RegExp objects.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CIS 228 The Internet 12/6/11 Forms and Validation.
Chapter 18 The HTML Tag
Regular Expressions In Javascript cosc What Do They Do? Does pattern matching on text We use the term “string” to indicate the text that the regular.
Validation Controls Assist your users with providing the correct type of input for your application Assist your users with providing the correct type of.
>> Form Data Validation in JavaScript
JavaScript, Sixth Edition
CHAPTER 13 FORM ENHANCEMENT & VALIDATION
CS 330 Class 7 Comments on Exam Programming plan for today:
In this session, you will learn about:
Working with Forms and Regular Expressions
Modern JavaScript Develop And Design
© 2015, Mike Murach & Associates, Inc.
Modern JavaScript Develop And Design
Functions, Regular expressions and Events
Today’s Objectives Week 12 Announcements ASP.NET
Form Validation (with jQuery, HTML5, and CSS)
Form Validation (with jQuery, HTML5, and CSS)
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

Modern JavaScript Develop And Design Instructor’s Notes Chapter 10 – Working with Forms Modern JavaScript Design And Develop Copyright © 2012 by Larry Ullman

Objectives Properly work with HTML forms using JavaScript Create inline errors as part of form validation Create tooltips Disable the submit button upon the form’s submission

More Objectives Perform common JavaScript interactions with standard form elements Generate dynamically linked select menus Write regular expression patterns Test regular expressions using different methods

Handling Forms Recap Add submit handler to form itself Always have a submit button Always use valid action attribute HTML5 supports browser-based form validation

Creating Error Messages function addErrorMessage(id, msg) { 'use strict'; var elem = document.getElementById(id); // Define the new span's ID value: var newId = id + 'Error'; // Check for the existence of the span: var span = document.getElementById(newId); if (span) { span.firstChild.value = msg; // Update } else { // Create new. // Create the span: span = document.createElement('span'); span.id = newId; span.className = 'error' span.appendChild(document.createTextNode(msg)); // Add the span to the parent: elem.parentNode.appendChild(span); elem.previousSibling.className = 'error'; } // End of main IF-ELSE. } // End of addErrorMessage() function.

Creating Tooltips showTooltip: function(e) { 'use strict'; // Get the event object: if (typeof e == 'undefined') var e = window.event; // Get the event target: var target = e.target || e.srcElement; target.previousSibling.lastChild.style.visibility = 'visible'; }, // End of showTooltip() function.

Disabling the Submit Button document.getElementById('submitButton').disabled = 'disabled'; document.getElementById('submitButton').disabled = true;

Getting Values var data = document.getElementById('comments').value; var data = document.getElementById('selectMenu').value; var data = document.getElementById('selectMenu').selectedIndex = 3; for (var i = 0, count = elem.options.length; i < count; i++) { // Use elem.options[i].selected/value/text }

Linked Lists

Checkboxes and Radio Buttons var which = document.getElementById('someCheckbox').checked; if (which.checked) { var value = document.getElementById('someCheckbox').value; }

Regular Expressions A way to test strings against patterns. Complicated! Represented by RegExp objects.

Creating RegExp var regexp = /pattern/; var regexp = /pattern/modifier;

Regex Functions test() exec() search() match()

Metacharacters CharacterMeaning \Escape ^Indicates the beginning of the string $Indicates the end of the string.Any single character except newline |Alternatives (or) [Start of a class ]End of a class (Start of a subpattern )End of a subpattern {Start of a quantifier }End of a quantifer

Quantifiers CharacterMeaning ?0 or 1 *0 or more +1 or more {x}Exactly x occurrences {x,y}Between x and y (inclusive) {x,}At least x occurrences

Character Classes ClassShortcutMeaning [0-9]\dAny digit [\f\r\t\n\v]\sAny white space [A-Za-z0-9]\wAny word character [^0-9]\DNot a digit [^\f\r\t\n\v]\SNot white space [^A-Za-z0-9]\WNot a word character