SlideShare a Scribd company logo
1 of 30
VADODARA INSTITUTE OF ENGINEERING
ACTIVE LEARNING ASSIGNMENT
Web Technology (2160708)
TOPIC : Form using HTML and Java scripts with validation
Presented By:
Kashyap Patel 150800107046
Krishna Patel 150800107047
Maitree Patel 150800107048
:
Content
 HTML Forms
• Introduction
• The <input> Element
• HTML Form Controls
• Form Attribute
Java script with validation
• Why do we need validation
• JavaScript form validation example
HTML Forms
Introduction :
• HTML Forms are required when some data needs to be collected.
• For example during registration information like name, email-id, address etc.
• A Form will take input form the site visitor and then post into a backend
application.
• It will perform require processing on the pass data based on defined business logic
inside application.
Introduction
• The HTML <form> element defines a form that is used to collect user input:
• <form>
.
form elements
.
</form>
• An HTML form contains form elements.
• Form elements are different types of input elements, like text fields, checkboxes,
radio buttons, submit buttons, and more.
The <input> Element
• The <input> element is the most important form element.
• The <input> element can be displayed in several ways, depending on
the type attribute.
• Here are some examples:
Type Description
<input type="text"> Defines a one-line text input field
<input type="radio"> Defines a radio button (for selecting one of
many choices)
<input type="submit"> Defines a submit button (for submitting the
form)
HTML Form Controls
1. Text Input
There are 3 types of text input control used on forms.
• Single line Text Input control
<form>
First name:<br>
<input type="text" name="firstname"><br>
</form>
file:///D:/wt/new%201.html
HTML Form Controls
• Password Input Control
This also single line Text input but it makes characters as soon as user enter
it.
Ex.Password < input type = “Password” name=“password”/>
HTML Form Controls
• Multiple line Input Control
This is used when user is required to give details that may be longer than single
sentence.
ex. <textarea rows = “3” cols = “5” >
HTML Form Controls
2. Checkbox Control
It is used when more than one option is required to be selected.
Ex.
<input type = "checkbox" name = "maths" checked>maths<br>
<input type = "checkbox" name = "wt" uchecked>wt<br>
HTML Form Controls
3. Radio Button
Radio buttons are used when out of many options just one option is required to be
selected.
• Ex<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
HTML Form Controls
4. Select box Control (Drop down Box)
It provide <option> tag to list out various option in form of drop down list.
Ex. <select name=“Subject”>
<option value=“maths”>maths</option>
<option value=“physics”>physics</option>
<option value=“chemistry”>chemistry</option>
HTML Form Controls
5. File upload box
If you want to allow user to upload the file used file upload box.
Name and accept are attribute.
Ex.<input type=“file" name=“upload" accept= “jpg.doc”/>
HTML Form Controls
6. Button controls
• Submit Button : This creates a button that automatically submits a form.
Ex. <form>
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
HTML Form Controls
• Reset Button: This creates a button that automatically reset form controls to their
initial value.
Ex.
First Name:<br>
<input type="text" name=“First Name”><br>
Last Name<br>
<input type="text" name=“Last Name" ><br><br>
<input type="submit" value="Submit">
<input type=“reset" value=“Reset">
HTML Form Controls
• Button : This creates a button that is used to trigger client side script when the
user click that button.
Ex. <input type=“button" value=“button">
• Image : This creates a clickable button but we can used ad image as background
of the button.
Ex. <input type = “image" src = "pexels-photo-547114.jpeg">
Form Attributes
1. The Action Attribute
• The action attribute defines the action to be performed when the form is
submitted.
• Normally, the form data is sent to a web page on the server when the user clicks
on the submit button.
Ex. <form action="/action_page.php">
2. The Name Attribute
• Each input field must have a name attribute to be submitted.
• If the name attribute is omitted, the data of that input field will not be sent at all.
Form Attributes
3. The Method attribute
• It specifies how to send form data.
• The form data is send to the page specified in the action attribute.
Ex. <form action="/action_page.php" method="get">
• when GET is used, the submitted form data will be visible in the page address
field:
/action_page.php?firstname=Mickey&lastname=Mouse
Ex. <form action="/action_page.php" method="post">
• POST if the form data contains sensitive or personal information. The POST
method does not display the submitted form data in the page address field.
Form Attributes
4. The Target Attribute
• The target attribute specifies if the submitted result will open in a new browser
tab, a frame, or in the current window.
• _blank : the response is display in new window or tab.
• _self : the response is displayed in same frame.
• _parent : the response is displayed in parent frame.
• _top : display full body of the window.
• _framename : display in name frame.
Java script with validation
• It is important to validate the form submitted by the user because it can have
inappropriate values. So validation is must.
• The JavaScript provides you the facility the validate the form on the client side so
processing will be fast than server-side validation. So, most of the web developers
prefer JavaScript form validation.
• Through JavaScript, we can validate name, password, email, date, mobile number
etc fields.
JavaScript form validation example
<html><body>
<script>
function validateform(){
var name=document.myform.name.value;
var password=document.myform.password.value;
if (name==null || name==""){
alert("Name can't be blank");
return false; }
else if(password.length<6){
alert("Password must be at least 6 characters long.");
return false; } } </script>
JavaScript form validation example
<body>
<form name="myform" method="post" action="abc.jsp" onsubmit="return validatef
orm()" >
Name: <input type="text" name="name"><br/>
Password: <input type="password" name="password"><br/>
<input type="submit" value="register">
</form>
JavaScript form validation example
<html>
<head> <title>Form Validation</title>
<script ty
pe="text/javascript"> </script>
function validate()
{ if( document.myForm.Name.value == "" )
{ alert( "Please provide your name!" );
document.myForm.Name.focus() ;
return false; }
JavaScript form validation example
if( document.myForm.EMail.value == "" )
{ alert( "Please provide your Email!" );
Document.myForm.EMail.focus() ;
return false; }
if( document.myForm.Zip.value == "" ||
isNaN(document.myForm.Zip.value ) ||
document.myForm.Zip.value.length != 5 )
{ alert( "Please provide a zip in the format #####." ); document.myForm.Zip.focus()
; return false; }
JavaScript form validation example
if( document.myForm.Country.value == "-1" )
{
alert( "Please provide your country!" );
return false; }
var emailID = document.myForm.EMail.value;
atpos = emailID.indexOf("@");
dotpos = emailID.lastIndexOf(".");
JavaScript form validation example
if (atpos < 1 || ( dotpos - atpos < 2 ))
{
alert("Please enter correct email ID")
document.myForm.EMail.focus() ;
return false; }
return( true );
}
</script>
</head>
JavaScript form validation example
<body>
<form action="/cgi-bin/test.cgi" name="myForm" onsubmit="return(validate());">
<table cellspacing="2" cellpadding="2" border="1">
<tr> <td align="right">Name</td>
<td><input type="text" name="Name" /></td> </tr>
<tr> <td align="right">EMail</td>
<td><input type="text" name="EMail" /></td> </tr>
JavaScript form validation example
<tr> <td align="right">Zip Code</td>
<td><input type="text" name="Zip" /></td> </tr>
<tr> <td align="right">Country</td>
<td> <select name="Country">
<option value="-1" selected>[choose yours] </option>
<option value="1">USA</option>
<option value="2">UK</option>
<option value="3">INDIA</option>
</select> </td> </tr>
JavaScript form validation example
<tr> <td align="right"></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
JavaScript form validation example
Thank You

More Related Content

What's hot

Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript BasicsVishal Mittal
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events WebStackAcademy
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScriptShahDhruv21
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays Reem Alattas
 
Java Script ppt
Java Script pptJava Script ppt
Java Script pptPriya Goyal
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation Salman Memon
 
Introduction to DOM
Introduction to DOMIntroduction to DOM
Introduction to DOMDaniel Bragais
 
Java script
Java scriptJava script
Java scriptShyam Khant
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
Html forms
Html formsHtml forms
Html formseShikshak
 
Php forms
Php formsPhp forms
Php formsAnne Lee
 

What's hot (20)

Jquery
JqueryJquery
Jquery
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Html forms
Html formsHtml forms
Html forms
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Html form tag
Html form tagHtml form tag
Html form tag
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Introduction to DOM
Introduction to DOMIntroduction to DOM
Introduction to DOM
 
Java script
Java scriptJava script
Java script
 
PHP - Introduction to PHP Forms
PHP - Introduction to PHP FormsPHP - Introduction to PHP Forms
PHP - Introduction to PHP Forms
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Html forms
Html formsHtml forms
Html forms
 
Jsp
JspJsp
Jsp
 
Php forms
Php formsPhp forms
Php forms
 

Similar to Form using html and java script validation

Similar to Form using html and java script validation (20)

Html tables, forms and audio video
Html tables, forms and audio videoHtml tables, forms and audio video
Html tables, forms and audio video
 
Html forms
Html formsHtml forms
Html forms
 
CSS_Forms.pdf
CSS_Forms.pdfCSS_Forms.pdf
CSS_Forms.pdf
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Html forms
Html formsHtml forms
Html forms
 
Html forms
Html formsHtml forms
Html forms
 
Lesson 15
Lesson 15Lesson 15
Lesson 15
 
FormL13.pptx
FormL13.pptxFormL13.pptx
FormL13.pptx
 
Getting Information through HTML Forms
Getting Information through HTML FormsGetting Information through HTML Forms
Getting Information through HTML Forms
 
Cmsc 100 (web forms)
Cmsc 100 (web forms)Cmsc 100 (web forms)
Cmsc 100 (web forms)
 
HTML-Forms
HTML-FormsHTML-Forms
HTML-Forms
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Designing web pages html forms and input
Designing web pages html  forms and inputDesigning web pages html  forms and input
Designing web pages html forms and input
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4
 
Html forms
Html formsHtml forms
Html forms
 
Chapter09
Chapter09Chapter09
Chapter09
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
uptu web technology unit 2 html
uptu web technology unit 2 htmluptu web technology unit 2 html
uptu web technology unit 2 html
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Forms
FormsForms
Forms
 

More from Maitree Patel

MACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block CiphersMACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block CiphersMaitree Patel
 
Software engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit designSoftware engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit designMaitree Patel
 
Dotnet :Attributes
Dotnet :AttributesDotnet :Attributes
Dotnet :AttributesMaitree Patel
 
Introduction of Memory Management
Introduction of Memory Management Introduction of Memory Management
Introduction of Memory Management Maitree Patel
 
Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Maitree Patel
 
Simple Mail Transfer Protocol
Simple Mail Transfer ProtocolSimple Mail Transfer Protocol
Simple Mail Transfer ProtocolMaitree Patel
 
Virtual circuit and Datagram network
Virtual circuit and Datagram networkVirtual circuit and Datagram network
Virtual circuit and Datagram networkMaitree Patel
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature FormulaMaitree Patel
 
Merge sort and Quick sort
Merge sort and Quick sortMerge sort and Quick sort
Merge sort and Quick sortMaitree Patel
 
Static Import and access modifiers
Static Import and access modifiersStatic Import and access modifiers
Static Import and access modifiersMaitree Patel
 

More from Maitree Patel (11)

MACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block CiphersMACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block Ciphers
 
Software engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit designSoftware engineering Testing technique,test case,test suit design
Software engineering Testing technique,test case,test suit design
 
Dotnet :Attributes
Dotnet :AttributesDotnet :Attributes
Dotnet :Attributes
 
Advance Java
Advance JavaAdvance Java
Advance Java
 
Introduction of Memory Management
Introduction of Memory Management Introduction of Memory Management
Introduction of Memory Management
 
Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Scheduling Definition, objectives and types
Scheduling Definition, objectives and types
 
Simple Mail Transfer Protocol
Simple Mail Transfer ProtocolSimple Mail Transfer Protocol
Simple Mail Transfer Protocol
 
Virtual circuit and Datagram network
Virtual circuit and Datagram networkVirtual circuit and Datagram network
Virtual circuit and Datagram network
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature Formula
 
Merge sort and Quick sort
Merge sort and Quick sortMerge sort and Quick sort
Merge sort and Quick sort
 
Static Import and access modifiers
Static Import and access modifiersStatic Import and access modifiers
Static Import and access modifiers
 

Recently uploaded

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoĂŁo Esperancinha
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 

Recently uploaded (20)

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 

Form using html and java script validation

  • 1. VADODARA INSTITUTE OF ENGINEERING ACTIVE LEARNING ASSIGNMENT Web Technology (2160708) TOPIC : Form using HTML and Java scripts with validation Presented By: Kashyap Patel 150800107046 Krishna Patel 150800107047 Maitree Patel 150800107048 :
  • 2. Content  HTML Forms • Introduction • The <input> Element • HTML Form Controls • Form Attribute Java script with validation • Why do we need validation • JavaScript form validation example
  • 3. HTML Forms Introduction : • HTML Forms are required when some data needs to be collected. • For example during registration information like name, email-id, address etc. • A Form will take input form the site visitor and then post into a backend application. • It will perform require processing on the pass data based on defined business logic inside application.
  • 4. Introduction • The HTML <form> element defines a form that is used to collect user input: • <form> . form elements . </form> • An HTML form contains form elements. • Form elements are different types of input elements, like text fields, checkboxes, radio buttons, submit buttons, and more.
  • 5. The <input> Element • The <input> element is the most important form element. • The <input> element can be displayed in several ways, depending on the type attribute. • Here are some examples: Type Description <input type="text"> Defines a one-line text input field <input type="radio"> Defines a radio button (for selecting one of many choices) <input type="submit"> Defines a submit button (for submitting the form)
  • 6. HTML Form Controls 1. Text Input There are 3 types of text input control used on forms. • Single line Text Input control <form> First name:<br> <input type="text" name="firstname"><br> </form> file:///D:/wt/new%201.html
  • 7. HTML Form Controls • Password Input Control This also single line Text input but it makes characters as soon as user enter it. Ex.Password < input type = “Password” name=“password”/>
  • 8. HTML Form Controls • Multiple line Input Control This is used when user is required to give details that may be longer than single sentence. ex. <textarea rows = “3” cols = “5” >
  • 9. HTML Form Controls 2. Checkbox Control It is used when more than one option is required to be selected. Ex. <input type = "checkbox" name = "maths" checked>maths<br> <input type = "checkbox" name = "wt" uchecked>wt<br>
  • 10. HTML Form Controls 3. Radio Button Radio buttons are used when out of many options just one option is required to be selected. • Ex<form> <input type="radio" name="gender" value="male" checked> Male<br> <input type="radio" name="gender" value="female"> Female<br> <input type="radio" name="gender" value="other"> Other </form>
  • 11. HTML Form Controls 4. Select box Control (Drop down Box) It provide <option> tag to list out various option in form of drop down list. Ex. <select name=“Subject”> <option value=“maths”>maths</option> <option value=“physics”>physics</option> <option value=“chemistry”>chemistry</option>
  • 12. HTML Form Controls 5. File upload box If you want to allow user to upload the file used file upload box. Name and accept are attribute. Ex.<input type=“file" name=“upload" accept= “jpg.doc”/>
  • 13. HTML Form Controls 6. Button controls • Submit Button : This creates a button that automatically submits a form. Ex. <form> First name:<br> <input type="text" value="Mickey"><br> Last name:<br> <input type="text" name="lastname" value="Mouse"><br><br> <input type="submit" value="Submit"> </form>
  • 14. HTML Form Controls • Reset Button: This creates a button that automatically reset form controls to their initial value. Ex. First Name:<br> <input type="text" name=“First Name”><br> Last Name<br> <input type="text" name=“Last Name" ><br><br> <input type="submit" value="Submit"> <input type=“reset" value=“Reset">
  • 15. HTML Form Controls • Button : This creates a button that is used to trigger client side script when the user click that button. Ex. <input type=“button" value=“button"> • Image : This creates a clickable button but we can used ad image as background of the button. Ex. <input type = “image" src = "pexels-photo-547114.jpeg">
  • 16. Form Attributes 1. The Action Attribute • The action attribute defines the action to be performed when the form is submitted. • Normally, the form data is sent to a web page on the server when the user clicks on the submit button. Ex. <form action="/action_page.php"> 2. The Name Attribute • Each input field must have a name attribute to be submitted. • If the name attribute is omitted, the data of that input field will not be sent at all.
  • 17. Form Attributes 3. The Method attribute • It specifies how to send form data. • The form data is send to the page specified in the action attribute. Ex. <form action="/action_page.php" method="get"> • when GET is used, the submitted form data will be visible in the page address field: /action_page.php?firstname=Mickey&lastname=Mouse Ex. <form action="/action_page.php" method="post"> • POST if the form data contains sensitive or personal information. The POST method does not display the submitted form data in the page address field.
  • 18. Form Attributes 4. The Target Attribute • The target attribute specifies if the submitted result will open in a new browser tab, a frame, or in the current window. • _blank : the response is display in new window or tab. • _self : the response is displayed in same frame. • _parent : the response is displayed in parent frame. • _top : display full body of the window. • _framename : display in name frame.
  • 19. Java script with validation • It is important to validate the form submitted by the user because it can have inappropriate values. So validation is must. • The JavaScript provides you the facility the validate the form on the client side so processing will be fast than server-side validation. So, most of the web developers prefer JavaScript form validation. • Through JavaScript, we can validate name, password, email, date, mobile number etc fields.
  • 20. JavaScript form validation example <html><body> <script> function validateform(){ var name=document.myform.name.value; var password=document.myform.password.value; if (name==null || name==""){ alert("Name can't be blank"); return false; } else if(password.length<6){ alert("Password must be at least 6 characters long."); return false; } } </script>
  • 21. JavaScript form validation example <body> <form name="myform" method="post" action="abc.jsp" onsubmit="return validatef orm()" > Name: <input type="text" name="name"><br/> Password: <input type="password" name="password"><br/> <input type="submit" value="register"> </form>
  • 22. JavaScript form validation example <html> <head> <title>Form Validation</title> <script ty pe="text/javascript"> </script> function validate() { if( document.myForm.Name.value == "" ) { alert( "Please provide your name!" ); document.myForm.Name.focus() ; return false; }
  • 23. JavaScript form validation example if( document.myForm.EMail.value == "" ) { alert( "Please provide your Email!" ); Document.myForm.EMail.focus() ; return false; } if( document.myForm.Zip.value == "" || isNaN(document.myForm.Zip.value ) || document.myForm.Zip.value.length != 5 ) { alert( "Please provide a zip in the format #####." ); document.myForm.Zip.focus() ; return false; }
  • 24. JavaScript form validation example if( document.myForm.Country.value == "-1" ) { alert( "Please provide your country!" ); return false; } var emailID = document.myForm.EMail.value; atpos = emailID.indexOf("@"); dotpos = emailID.lastIndexOf(".");
  • 25. JavaScript form validation example if (atpos < 1 || ( dotpos - atpos < 2 )) { alert("Please enter correct email ID") document.myForm.EMail.focus() ; return false; } return( true ); } </script> </head>
  • 26. JavaScript form validation example <body> <form action="/cgi-bin/test.cgi" name="myForm" onsubmit="return(validate());"> <table cellspacing="2" cellpadding="2" border="1"> <tr> <td align="right">Name</td> <td><input type="text" name="Name" /></td> </tr> <tr> <td align="right">EMail</td> <td><input type="text" name="EMail" /></td> </tr>
  • 27. JavaScript form validation example <tr> <td align="right">Zip Code</td> <td><input type="text" name="Zip" /></td> </tr> <tr> <td align="right">Country</td> <td> <select name="Country"> <option value="-1" selected>[choose yours] </option> <option value="1">USA</option> <option value="2">UK</option> <option value="3">INDIA</option> </select> </td> </tr>
  • 28. JavaScript form validation example <tr> <td align="right"></td> <td><input type="submit" value="Submit" /></td> </tr> </table> </form> </body> </html>