LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.

Slides:



Advertisements
Similar presentations
Events Part III The event object. Learning Objectives By the end of this lecture, you should be able to: – Learn to use the hover() function – Work with.
Advertisements

Chapter 131 Applets and HTML Chapter Reminders Project 8 due Dec 10:30 pm Project 6 regrades due by midnight tonight –Submit all files (including.
UWWD In our quest to eliminate bad websites, we present…. HALLELUJAH!!
CS428 Web Engineering Lecture 15 Introduction to Jquery.
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Definition from Wikipedia.  The Prototype JavaScript Framework  implemented as a single file of JavaScript code  named prototype.js (
4.1 JavaScript Introduction
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JQUERY | INTRODUCTION. jQuery  Open source JavaScript library  Simplifies the interactions between  HTML document, or the Document Object Model (DOM),
Interacting with a Web Page using JavaScript Mat Kelly GTAI Presentation January 10, 2014.
Review IDIA 619 Spring 2013 Bridget M. Blodgett. HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user.
13. jQuery See the official documentation at  See the terse API documentation at
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
JavaScript Frameworks Presented by Kyle Goins Also see:
Animation & Effects Using JQuery. What is jQuery? jQuery is a lightweight, JavaScript library. The purpose of jQuery is to make it much easier to use.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
Introduction to JavaScript CS101 Introduction to Computing.
Computer Science and Software Engineering© 2014 Project Lead The Way, Inc. HTML5 Evolving Standards JavaScript.
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
JavaScript Library. What is jQuery jQuery is a lightweight JavaScript library. The purpose is to make it easier to use JavaScript code on your website.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
Review of the DOM Node properties and methods Some ways of accessing nodes Appending, copying and removing nodes Event handling – Inline – Scripting –
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Welcome to jQuery jQuery is one of many available libraries that – Provide functions for manipulating the web page With fairly good performance – Help.
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
Dawn Pedersen. What is JavaScript? JavaScript is the basis for both jQuery and Spry applications JavaScript is referred to as a client-side scripting.
IS2802 Introduction to Multimedia Applications for Business Lecture 07: Introduction to jQuery Rob Gleasure
Unit 13 –JQuery Basics Instructor: Brent Presley.
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
SHAREPOINT & JQUERY. Hi, my name and I am a product manager at lightning tools. I have been working with SharePoint for 5 years.
Introduction to JQuery COGS 187A – Fall JQuery jQuery is a JavaScript library, and allows us to manipulate HTML and CSS after the page has been.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
MICROSOFT AJAX CDN (CONTENT DELIVERY NETWORK) Make Your ASP.NET site faster to retrieve.
 A Javascript library designed to simplify client-side scripting of HTML.
SharePoint & jQuery. About me Phill Duffy – Product Manager at Lightning Tools Ltd – Author of ‘Pro SharePoint with jQuery’ – MCTS Application Developer.
JQuery is a fast, small, and feature-rich javascript library. It makes things like HTML document traversal and manipulation, event handling, animation,
JQuery Element & Attribute Selectors, Events, HTML Manipulation, & CSS Manipulation.
JQuery Fundamentals Introduction Tutorial Videos
Introduction to.
HTML Elements with JavaScript and DOM Events
Tek Raj Chhetri Code for Humans not for machine.
Introduction to Web programming
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
The Cliff Notes Version
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
MIS JavaScript and API Workshop (Part 2)
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
Javascript and JQuery SRM DSC.
An introduction to jQuery
E-commerce Applications Development
An introduction to jQuery
Getting started with jQuery
An introduction to jQuery
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
Web Programming and Design
Presentation transcript:

LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016

Intro ■Previous class we worked on using JavaScript to do validation of HTML forms. ■Today we're going to stick with form validation, but we're going to use jQuery instead. ■We'll use the same format as most classes: I'm going to walk through the basics of jQuery so that when you get to the lab you have enough information and perspective to dig in right away. 2

What is jQuery? ■jQuery is a JavaScript framework/library. ■jQuery expands and extends JavaScript, making development work more efficient in a number of different ways. ■jQuery is NOT a language, nor does it replace JavaScript. You still have all the base functions and syntax that come with JavaScript, but you get more and better tools. 3

Why use jQuery? ■jQuery provides a means of interacting with the pieces of your Web page in a manner similar to how we use CSS. –Makes for an easier learning curve for those already comfortable with HTML and CSS –Makes it easier to think about your Web page ■jQuery adds functions that simplify many tasks that have become basic when building interactive Web pages. 4

Why use jQuery? (cont) ■Code Sample #1 –JavaScript: var old_school = document.getElementById('input1').value; –jQuery: var new_school = $("#input1").val(); 5

jQuery – Basic Syntax ■Code Sample #1 – var new_school = $("#input1").val(); ■ var – Tells JavaScript that we're creating a variable ■ new_school – Name of the Variable ■ $() - Activates jQuery –Actually more complicated than this, but this is a good way to start thinking about it –In the jQuery API documentation, this piece is referred to as the "selector". 6

jQuery – Basic Syntax (cont) ■Code Sample #1 – var new_school = $("#input1").val(); ■ "#input1" - Tells jQuery what part of your page you're going to work with; in this case, the INPUT field with id="input1" ■.val() - The jQuery function we're applying to the INPUT field with id="input1" –In this case, we're asking the val() function to retrieve the text contained in the INPUT field with id="input1" 7

jQuery Functions ■Today we're going to focus on two groupings of jQuery functions: –HTML Functions – Retrieve and manipulate your Web page HTML and CSS –Event Functions – Monitor elements of your web page for specific actions, calling code when those actions occur ■Resources –Lab Handout – This has a list of all the jQuery functions you'll need for today's lab –jQuery API - –W3 Schools - 8

jQuery HTML Functions ■Read/Write - Most jQuery functions are designed to support the retrieval of information AND the changing of information, depending on how you call the function. ■Code Sample #2: var initialValue = $("#scary").val(); $("#scary").val("But Sharks are even more Scary"); 9

jQuery HTML Functions (cont) ■Code Sample #2: var initialValue = $("#scary").val(); $("#scary").val("But sharks are even more scary"); ■First line uses the val() function to grab the text from the INPUT field that uses ID="scary" ■The second line uses the val() function, but providing an argument tells jQuery to change the value of the INPUT field that uses ID="scary" 10

jQuery Event Functions ■Code Sample #3: $("#green").click(function() { $("#colorBox").css("background-color", "green").text("Green!"); }); ■ $("#green") - The selector (piece of the page) that we're going to work with ■. click() - The jQuery event function that we are binding to the selector ■ function(){ - Initiates the function that we want to run when the click() function is triggered 11

jQuery Event Functions (cont) ■Code Sample #3: $("#green").click(function() { $("#colorBox").css("background-color", "green").text("Green!"); }); ■ $("#colorBox") - The selector we want to alter as part of the function called by click() ■.css() - The jQuery function we're attaching to the selector ■ ("backround-color", "green") - The CSS key and value we're going to change ■.text("Green!") - Using jQuery's "chaining" feature, we're attaching a second change to the selector. 12

jQuery Event Functions (cont) ■Code Sample #4 $("#green").hover(function() { $("#colorBox").css("background-color", "green").text("Green!"); }); ■Only change is replacing the.click() function with the.hover() function 13

Why use jQuery? (part 2) ■Additional Benefits: –Cross-browser compatibility –Event triggers are removed from the HTML –Effects Functions – very fun stuff –jQuery Plugins –jQuery is built into most contemporary CMS (Content Management System; e.g. WordPress) 14

When to use jQuery? ■Whenever possible, assuming that you find it more friendly than base JavaScript ■Actually easier to answer the opposite question: When NOT to use jQuery? –When writing high-end and complex JavaScript tools –When adding jQuery to your application environment would cause problems: ■Creates conflicts with other JavaScript frameworks and libraries ■If your JavaScript needs to be able to run across multiple environments, some of which may not (easily) support jQuery 15

Adding jQuery to your page ■Step 1: Load the Library –Add it to your HTML pretty much like you would any JS file –For today's lab: –Code Sample #0 16

Adding jQuery to your page (cont) ■Step 1: Load the Library (cont) – Load local, or from a CDN (Content Delivery Network)? ■ CDN is preferred – Compressed vs. Full? ■ Compressed (Min) is preferred – Which version? ■ Most recent, unless an earlier version is required – Where to add it in the HTML? ■ Bottom of the page is preferred, though not always workable 17

Adding jQuery to your page (cont) ■Step 2: Create your.JS file –Start the same way you would create a regular.JS file to hold your JavaScript –IMPORTANT STEP: Wrap all your jQuery within a $(document).ready() statement: $(document).ready(function() { //jQuery code goes in here } –Code Sample #0 18

Adding jQuery to your page (cont) ■Step 3: Add your.JS file to your HTML file –Add it like you would another JS file: –Best Practice: Add it below the HTML that loads the jQuery library –Code Sample #0 19

Adding jQuery to your page (cont) ■IMPORTANT: Other Environments –Today's examples show the way to add jQuery to a basic HTML file. –When adding to other environments, you may have to use somewhat different placement and code. –Both Drupal and WordPress (recent versions) include jQuery as part of their core application, and they load it differently. ■You will need to make some environment-specific adjustments to your jQuery code, but it's all well documented; Google it. 20

Principals of Client-Side Validation ■Including this from last week as a reminder: –Client-side form validation is almost always about enhancing the user interface –Client-side form validation DOES NOT replace server-side validation 21

Vocabulary ■[insert per curriculum and lab] 22

Additional Resources ■[insert per curriculum and lab] 23