SlideShare a Scribd company logo
Web Authoring

        Topic 22 –
Validation on Web Forms
Objectives
Students should able to:
1. Using Javascript
2. Identify and use the various JavaScript
    features:
  • Custom and Build-in Functions
  • Event Handler
  • Input and Output of document text
  • document.write()
Objectives
Students should able to:
3. What is form validation?
4. How is form validation carried out using
   Javascript
Javascript Declarations
var ite_Class_Size = 43;     All javascript
                             statement must
var ite Class Size = 43;     end with ;

var iteClassCA = “Mr Sua”;

var htmlTeacher = new String(“Mr Sua”);
Syntax of Javascript
var result;         Declare a variable called result.

result = 12 * 20;       Perform arithmetic operation
                        and store it in variable result
alert(“The result is “ + result);

      Does a string concatenation.

Display the output in a pop-up box.
Functions
A function is a collection of codes.


This set of codes will be executed by a
call to the function or an event.

Functions can be placed in either the
<head> or <body>
Functions
<head>
<script type="text/javascript">
function displaymessage()
{
      alert("Hello World!");
}
</script></head>
<body><form>
<input type="button" value="Click me!"
onclick="displaymessage()" />
</form>
</body>
Date object
<SCRIPT LANGUAGE=”JavaScript”>
    var todayDate = new Date();
    document.write("Today's Date is ")
    document.write(todayDate.getDate());
    document.write(todayDate.getMonth());
    document.write(todayDate.getYear());
</SCRIPT>
Date object
<SCRIPT LANGUAGE=”JavaScript”>
    var todayDate = new Date();
    document.write(todayDate.getHours());
    document.write(todayDate.getMinutes());
    document.write(todayDate.getSeconds());
</SCRIPT>
Form Validation
What is form validation?
Form validation is the process of checking that a
form has been filled in correctly before it is
processed.
Form Validation
There are two main methods for validating forms:
- server-side (using CGI scripts, ASP, etc), and
- client-side (usually done using JavaScript).
Server-side validation is more secure but often
more tricky to code, whereas client-side
(JavaScript) validation is easier to do and
quicker too (the browser doesn't have to
connect to the server to validate the form).
Form Validation
There are two main methods for validating forms:




  Client-side form validation (usually with JavaScript embedded in the Web page)
Form Validation
There are two main methods for validating forms:




    Server-side form validation (usually performed by a CGI or ASP script)
Validate_Form
Example on validating forms:
   Open this page
  The first part of the form is the form tag:
  <code />
  <form name="contact_form"
  method="post"action="/cgi-
  bin/articles/development/javascript/for
  m-validation-with-
  javascript/contact_simple.cgi"onsubmit=
  "return validate_form ( );">
Validate_Form
Example on validating forms:
   Open this page
  The first part of the form is the form tag:
  <code />
  <form name="contact_form"
  method="post"action="/cgi-
  bin/articles/development/javascript/for
  m-validation-with-
  javascript/contact_simple.cgi"onsubmit=
  "return validate_form ( );">
Validate_Form
Example on validating forms:
   Open this page

   The rest of the form prompts the user to enter their name
   into a form field called contact_name, and adds a "Send
   Details" submit button:
   <code /><h1>Please Enter Your Name</h1><p>Your
   Name: <input type="text"
   name="contact_name"></p><p><input type="submit"
   name="send" value="Send Details"></p></form>
Validate_Form
Example on validating forms:
   Open this page
   <script type="text/javascript">
   <!--
   function validate_form ( )
   { valid = true;
         if ( document.contact_form.contact_name.value = = "" )
          { alert ( "Please fill in the 'Your Name' box." );
           valid = false; }
      return valid;
   }
   //-->
   </script>

More Related Content

DOCX
Validation using javascripts by karan chanana
PDF
PWA night vol.11 20191218
PPTX
Make an html validator extension
PDF
Form Validation NG
PDF
Devoxx 2014-webComponents
PDF
Binding components, events + data sources in HTML + JS
PPTX
Reusable ui components
PDF
Rails GUI Development with Ext JS
Validation using javascripts by karan chanana
PWA night vol.11 20191218
Make an html validator extension
Form Validation NG
Devoxx 2014-webComponents
Binding components, events + data sources in HTML + JS
Reusable ui components
Rails GUI Development with Ext JS

Viewers also liked (20)

PPTX
Web topic 18 conflict resolution in css
PPTX
Web topic 21 pass info via javascript
PPTX
Web topic 17 font family in css
PPTX
Web topic 15 2 basic css layout
PPTX
Web topic 20 1 html forms
PPTX
Web topic 16 css workflow
PPTX
Web topic 20 2 html forms
PPTX
Web topic 29 w3 c page validation
PPTX
Web topic 23 web accessibility
PPTX
Web topic 25 mobile optimized website
PPTX
Web topic 30 ensure web contents meet
PPTX
Web topic 24 usage of web browser
PPTX
Web topic 28. w3 c standards and guidelines
PPTX
Web topic 32 validate web contents
PPTX
Web topic 15 1 basic css layout
PPTX
Web topic 14 cascading style sheets
PPTX
Web topic 29 w3 c page validation
PPTX
Web topic 26 browser compatibilty and security
PPTX
Web topic 33 publish websites
PPTX
Web topic 31 setup remote site
Web topic 18 conflict resolution in css
Web topic 21 pass info via javascript
Web topic 17 font family in css
Web topic 15 2 basic css layout
Web topic 20 1 html forms
Web topic 16 css workflow
Web topic 20 2 html forms
Web topic 29 w3 c page validation
Web topic 23 web accessibility
Web topic 25 mobile optimized website
Web topic 30 ensure web contents meet
Web topic 24 usage of web browser
Web topic 28. w3 c standards and guidelines
Web topic 32 validate web contents
Web topic 15 1 basic css layout
Web topic 14 cascading style sheets
Web topic 29 w3 c page validation
Web topic 26 browser compatibilty and security
Web topic 33 publish websites
Web topic 31 setup remote site
Ad

Similar to Web topic 22 validation on web forms (20)

PDF
JavaScript - Chapter 14 - Form Handling
PPTX
Form Validation in JavaScript
PPTX
Javascript validating form
PPTX
Form using html and java script validation
PPT
validation & regular expression chacteristics
DOCX
Option #1- Form Validation in JavaScript 1- In your text editor- open.docx
DOCX
Java script
RTF
Html basics 11 form validation
 
PPTX
Javascript ch7
PPTX
Accessible dynamic forms
PPTX
Web Development
PPTX
javaScript tutorial
PPT
Javascript1
KEY
HTML5 Form Validation
PPTX
Javascript
PDF
Web Forms People Don't Hate
KEY
Building & Breaking Web Forms with Quaid-JS
PPTX
Asp.NET Validation controls
PDF
PDF
JavaScript - Chapter 14 - Form Handling
Form Validation in JavaScript
Javascript validating form
Form using html and java script validation
validation & regular expression chacteristics
Option #1- Form Validation in JavaScript 1- In your text editor- open.docx
Java script
Html basics 11 form validation
 
Javascript ch7
Accessible dynamic forms
Web Development
javaScript tutorial
Javascript1
HTML5 Form Validation
Javascript
Web Forms People Don't Hate
Building & Breaking Web Forms with Quaid-JS
Asp.NET Validation controls
Ad

More from CK Yang (10)

PPTX
Web topic 27 class test
PPTX
Web topic 13 html validation tools
PPTX
Web topic 12 tables in html
PPTX
Web topic 11 importance of html validation
PPTX
Web topic 10 2 web design basics
PPTX
Web topic 9 navigation and link
PPTX
Web topic 8 listings in html
PPTX
Web topic 7 html tags for links
PPTX
Web topic 5 text formatting
PPTX
Web topic 4 style in html
Web topic 27 class test
Web topic 13 html validation tools
Web topic 12 tables in html
Web topic 11 importance of html validation
Web topic 10 2 web design basics
Web topic 9 navigation and link
Web topic 8 listings in html
Web topic 7 html tags for links
Web topic 5 text formatting
Web topic 4 style in html

Recently uploaded (20)

PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
PDF
Doc9.....................................
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
This slide provides an overview Technology
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
PDF
Why Endpoint Security Is Critical in a Remote Work Era?
PPTX
How Much Does It Cost to Build a Train Ticket App like Trenitalia in Italy.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Google’s NotebookLM Unveils Video Overviews
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
A Day in the Life of Location Data - Turning Where into How.pdf
madgavkar20181017ppt McKinsey Presentation.pdf
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
agentic-ai-and-the-future-of-autonomous-systems.pdf
Doc9.....................................
Chapter 2 Digital Image Fundamentals.pdf
This slide provides an overview Technology
Enable Enterprise-Ready Security on IBM i Systems.pdf
Why Endpoint Security Is Critical in a Remote Work Era?
How Much Does It Cost to Build a Train Ticket App like Trenitalia in Italy.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Google’s NotebookLM Unveils Video Overviews
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Transforming Manufacturing operations through Intelligent Integrations
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function

Web topic 22 validation on web forms

  • 1. Web Authoring Topic 22 – Validation on Web Forms
  • 2. Objectives Students should able to: 1. Using Javascript 2. Identify and use the various JavaScript features: • Custom and Build-in Functions • Event Handler • Input and Output of document text • document.write()
  • 3. Objectives Students should able to: 3. What is form validation? 4. How is form validation carried out using Javascript
  • 4. Javascript Declarations var ite_Class_Size = 43; All javascript statement must var ite Class Size = 43; end with ; var iteClassCA = “Mr Sua”; var htmlTeacher = new String(“Mr Sua”);
  • 5. Syntax of Javascript var result; Declare a variable called result. result = 12 * 20; Perform arithmetic operation and store it in variable result alert(“The result is “ + result); Does a string concatenation. Display the output in a pop-up box.
  • 6. Functions A function is a collection of codes. This set of codes will be executed by a call to the function or an event. Functions can be placed in either the <head> or <body>
  • 7. Functions <head> <script type="text/javascript"> function displaymessage() { alert("Hello World!"); } </script></head> <body><form> <input type="button" value="Click me!" onclick="displaymessage()" /> </form> </body>
  • 8. Date object <SCRIPT LANGUAGE=”JavaScript”> var todayDate = new Date(); document.write("Today's Date is ") document.write(todayDate.getDate()); document.write(todayDate.getMonth()); document.write(todayDate.getYear()); </SCRIPT>
  • 9. Date object <SCRIPT LANGUAGE=”JavaScript”> var todayDate = new Date(); document.write(todayDate.getHours()); document.write(todayDate.getMinutes()); document.write(todayDate.getSeconds()); </SCRIPT>
  • 10. Form Validation What is form validation? Form validation is the process of checking that a form has been filled in correctly before it is processed.
  • 11. Form Validation There are two main methods for validating forms: - server-side (using CGI scripts, ASP, etc), and - client-side (usually done using JavaScript). Server-side validation is more secure but often more tricky to code, whereas client-side (JavaScript) validation is easier to do and quicker too (the browser doesn't have to connect to the server to validate the form).
  • 12. Form Validation There are two main methods for validating forms: Client-side form validation (usually with JavaScript embedded in the Web page)
  • 13. Form Validation There are two main methods for validating forms: Server-side form validation (usually performed by a CGI or ASP script)
  • 14. Validate_Form Example on validating forms: Open this page The first part of the form is the form tag: <code /> <form name="contact_form" method="post"action="/cgi- bin/articles/development/javascript/for m-validation-with- javascript/contact_simple.cgi"onsubmit= "return validate_form ( );">
  • 15. Validate_Form Example on validating forms: Open this page The first part of the form is the form tag: <code /> <form name="contact_form" method="post"action="/cgi- bin/articles/development/javascript/for m-validation-with- javascript/contact_simple.cgi"onsubmit= "return validate_form ( );">
  • 16. Validate_Form Example on validating forms: Open this page The rest of the form prompts the user to enter their name into a form field called contact_name, and adds a "Send Details" submit button: <code /><h1>Please Enter Your Name</h1><p>Your Name: <input type="text" name="contact_name"></p><p><input type="submit" name="send" value="Send Details"></p></form>
  • 17. Validate_Form Example on validating forms: Open this page <script type="text/javascript"> <!-- function validate_form ( ) { valid = true; if ( document.contact_form.contact_name.value = = "" ) { alert ( "Please fill in the 'Your Name' box." ); valid = false; } return valid; } //--> </script>