SlideShare a Scribd company logo
1 of 8
HFJS – Book
Review Ch7
Brady Cheng
Agenda
 What is Form?
 How to Get Its Value?
 Events Invoked by Form
 Warning for Empty Input
 Warning for NaN
 Warning for Specific Patterns
Form
 We   want to verify a form and its inputs, i.e.
Get value
 Method1
    <inputid="msgId" name=“msgName" type="text“/>
    Use getElementById(“msgId”);

 Method2
    Use form object
    <input id="msgId" name=“msgName" type="text“
            onclick=“verifyFunc(this.form);”/>
     function verifyFunc(theForm)
     {
        var value = theForm[“msgName”].value ;
     }
                                         property
Events

                      onchange
   onfocus            & onblur
    select    input          leave



             onblur
Empty Input
 In   HTML
  <div class = "field">
    Enter something:
    <input id="id1" name="name1" size="40"
           onblur="isEmpty( this,
                        document.getElementById('spanId1'));" />
    <span id="spanId1" class="help"> </span>
  </div>
 In   JS
  function isEmpty(form, helpText){
            if(form.value.length == 0){                same
                if(helpText != null){
                     helpText.innerHTML = "NULL";
                }
             } return;
  }
NaN(Not a Number)
 Use   isNaN() build-in function

  if( isNaN(form.value) )
  {
        alert(“this is not a number”);
  }
Specific Patterns
 We  can use Regular expressions to
  match/filter the wanted patterns
 However, I want to skip this part until I start
  to doc the Perl introduction! 
       var regex = /some regex/;
       if( regex.test(form.value))
       {
           //do something when matched
       }
       else
       {
          //do something when mismatched
       }

More Related Content

What's hot

Java script frame window
Java script frame windowJava script frame window
Java script frame window
H K
 

What's hot (13)

Oracle EBS R12 Sales order personalization
Oracle EBS R12 Sales order personalizationOracle EBS R12 Sales order personalization
Oracle EBS R12 Sales order personalization
 
Db locking
Db lockingDb locking
Db locking
 
Structure and union
Structure and unionStructure and union
Structure and union
 
Ex
ExEx
Ex
 
Personalization to restrict subinventory lov in interorganization transfer كي...
Personalization to restrict subinventory lov in interorganization transfer كي...Personalization to restrict subinventory lov in interorganization transfer كي...
Personalization to restrict subinventory lov in interorganization transfer كي...
 
Personalization to restrict values in customer name and number lov in sales o...
Personalization to restrict values in customer name and number lov in sales o...Personalization to restrict values in customer name and number lov in sales o...
Personalization to restrict values in customer name and number lov in sales o...
 
Informatics Practices/ Information Practices Project (IP Project Class 12)
Informatics Practices/ Information Practices Project (IP Project Class 12)Informatics Practices/ Information Practices Project (IP Project Class 12)
Informatics Practices/ Information Practices Project (IP Project Class 12)
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Policy Injection in ASP.NET using Enterprise Library 3.0
Policy Injection in ASP.NET using Enterprise Library 3.0Policy Injection in ASP.NET using Enterprise Library 3.0
Policy Injection in ASP.NET using Enterprise Library 3.0
 
Structures and Unions
Structures and UnionsStructures and Unions
Structures and Unions
 
Composition in JavaScript
Composition in JavaScriptComposition in JavaScript
Composition in JavaScript
 
Java script frame window
Java script frame windowJava script frame window
Java script frame window
 
Restrict user from use account aliases incompatible with transaction action
Restrict user from use account aliases incompatible with transaction actionRestrict user from use account aliases incompatible with transaction action
Restrict user from use account aliases incompatible with transaction action
 

Viewers also liked (9)

Javascipt ch4 & ch5
Javascipt ch4 & ch5Javascipt ch4 & ch5
Javascipt ch4 & ch5
 
Javascript ch3
Javascript ch3Javascript ch3
Javascript ch3
 
Ruby introduction part1
Ruby introduction part1Ruby introduction part1
Ruby introduction part1
 
Javascipt ch1
Javascipt ch1Javascipt ch1
Javascipt ch1
 
RoR guide_p1
RoR guide_p1RoR guide_p1
RoR guide_p1
 
Javascript ch2
Javascript ch2Javascript ch2
Javascript ch2
 
Javascript ch8
Javascript ch8Javascript ch8
Javascript ch8
 
design pattern overview
design pattern overviewdesign pattern overview
design pattern overview
 
Javascript ch6
Javascript ch6Javascript ch6
Javascript ch6
 

Similar to Javascript ch7

New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
nidhileena
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
Phúc Đỗ
 
Add two numbers karan chanana
Add two numbers karan chananaAdd two numbers karan chanana
Add two numbers karan chanana
karan chanana
 
Add two numbers karan chanana
Add two numbers karan chananaAdd two numbers karan chanana
Add two numbers karan chanana
karan info
 
Add two numbers karan chanana
Add two numbers karan chananaAdd two numbers karan chanana
Add two numbers karan chanana
karanchanan
 
Add two numbers bykaran chanana
Add two numbers  bykaran chananaAdd two numbers  bykaran chanana
Add two numbers bykaran chanana
karan info
 

Similar to Javascript ch7 (20)

Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Specs2
Specs2Specs2
Specs2
 
WD programs descriptions.docx
WD programs descriptions.docxWD programs descriptions.docx
WD programs descriptions.docx
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Improving Correctness with Types
Improving Correctness with TypesImproving Correctness with Types
Improving Correctness with Types
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
 
javascript-variablesanddatatypes-130218094831-phpapp01.pdf
javascript-variablesanddatatypes-130218094831-phpapp01.pdfjavascript-variablesanddatatypes-130218094831-phpapp01.pdf
javascript-variablesanddatatypes-130218094831-phpapp01.pdf
 
Add two numbers karan chanana
Add two numbers karan chananaAdd two numbers karan chanana
Add two numbers karan chanana
 
Add two numbers karan chanana
Add two numbers karan chananaAdd two numbers karan chanana
Add two numbers karan chanana
 
Add two numbers karan chanana
Add two numbers karan chananaAdd two numbers karan chanana
Add two numbers karan chanana
 
Add two numbers bykaran chanana
Add two numbers  bykaran chananaAdd two numbers  bykaran chanana
Add two numbers bykaran chanana
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Javascript ch7

  • 1. HFJS – Book Review Ch7 Brady Cheng
  • 2. Agenda  What is Form?  How to Get Its Value?  Events Invoked by Form  Warning for Empty Input  Warning for NaN  Warning for Specific Patterns
  • 3. Form  We want to verify a form and its inputs, i.e.
  • 4. Get value  Method1  <inputid="msgId" name=“msgName" type="text“/>  Use getElementById(“msgId”);  Method2  Use form object  <input id="msgId" name=“msgName" type="text“ onclick=“verifyFunc(this.form);”/> function verifyFunc(theForm) { var value = theForm[“msgName”].value ; } property
  • 5. Events onchange onfocus & onblur select input leave onblur
  • 6. Empty Input  In HTML <div class = "field"> Enter something: <input id="id1" name="name1" size="40" onblur="isEmpty( this, document.getElementById('spanId1'));" /> <span id="spanId1" class="help"> </span> </div>  In JS function isEmpty(form, helpText){ if(form.value.length == 0){ same if(helpText != null){ helpText.innerHTML = "NULL"; } } return; }
  • 7. NaN(Not a Number)  Use isNaN() build-in function if( isNaN(form.value) ) { alert(“this is not a number”); }
  • 8. Specific Patterns  We can use Regular expressions to match/filter the wanted patterns  However, I want to skip this part until I start to doc the Perl introduction!  var regex = /some regex/; if( regex.test(form.value)) { //do something when matched } else { //do something when mismatched }