What is HTML Form and its used for in HTML?

what is Form

Table of Contents

What is HTML Form?

  • HTML Form एक Document का एक Section है जिसमें Text Field, Password Field, Checkbox, Radio Button, Submit Button, Menu इत्यादि जैसे Controls शामिल हैं।
  • User Input Data को Collect करने के लिए HTML Form का Use किया जाता है। Processing के लिए User Input Data को अक्सर Server पर Send किया जाता है।
				
					<!DOCTYPE html>
<html>
<head>
  <title>HTML Form Example</title>
</head>
<body>
  <h2>Example Form</h2>

  <form method="POST" action="submit.php">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required><br><br>

    <input type="submit" value="Submit">
  </form>
</body>
</html>
				
			

Why Use HTML Form

  • HTML Form Use Site Visitor से कुछ Data Collect करने के लिए किया जाता हैं।
  • For Example: यदि कोई User Internet पर कुछ Items खरीदना चाहता है, तो उसे Shipping के लिए Address और Credit/Debit Card का Details जैसे Form भरने होंगे ताकि Items दिए गए Address पर Send किया जा सके।

Form Element

  • HTML <form> Element User से Input लेने के लिए एक Document Section प्रदान करता है। यह Web Server को जानकारी Submit करने के लिए विभिन्न Interactive Controls प्रदान करता है जैसे Text Field, Text Area, Password Field इत्यादि।

Note: <form> Element स्वयं एक Form नहीं बनाता है, लेकिन यह Container है जिसमें सभी आवश्यक Form Element होते हैं, जैसे <input>, <label>, आदि।

Syntax :-

				
					<form>
  Form Elements
  <label for="name">Name:</label>
  <input type="text" id="name" name="name" required><br><br>
</form>
				
			

Form Attribute

Action Attribute

  • <form> Element की Action Attribute Form Submit करते समय Form पर की जाने वाली प्रक्रिया को Define करते है, या यह Form की जानकारी को Process करने के लिए एक URI (Universal Resource Identifier) है।
  • Action Attribute Value उस Web Page को Define करता है जहां जानकारी आगे बढ़ती है। यह .php, .jsp, .asp, आदि या कोई भी URL हो सकता है जहाँ आप अपने Form को Process करना चाहते हैं।
				
					<form action="action_page.php">
    Form Element
</form>

				
			

Target Attribute

  • Target Attribute निर्दिष्ट (Specified) करती है कि Form Submit करने के बाद प्राप्त Resource को कहाँ Display किया जाए।
  • Target Attribute में निम्न में से कोई एक Value हो सकता है:
    • _self – Default। Document को उसी Window/Tab में खोलता है जिस पर Click किया गया था।
    • _blank – Document को एक New Window या Tab में खोलता है।
    • _parent – Document को Parent Frame में खोलता है।
    • _top – Document को पूरी Window में खोलता है।
				
					<form action="action_page.php" target="_blank">
    Form Element
</form>

				
			

Method Attribute

  • Method Attribute HTTP Method को Define करता है जिसका Use Browser Form को Submit करने के लिए किया जाता है। Method Attribute के Possible Value हो सकते हैं:
    • get: Form Submit करते समय Method Attribute का Get Value होता है। यह Default Value होता है। लेकिन यह सुरक्षित नहीं है क्योंकि Form Submit करने के बाद यह URL में Data Display करता है।
				
					<form action="action_page.php" method="get">
    Form Element
</form>

				
			
    • post: जब हम Sensitive Data को Process करना चाहते हैं तो हम Method Attribute के Post value को Use कर सकते हैं क्योंकि यह URL में Submit किए गए Data को Display नहीं करता है।
				
					<form action="action_page.php" method="post" >
    Form Element
</form>

				
			

Autocomplete Attribute

  • Autocomplete Attribute निर्दिष्ट (Specified) करती है कि किसी Form को Autocomplete “ on ” या “ off ” होना चाहिए।
  • Autocomplete Attribute का Default Value “on” होता है।\
				
					<form action="action_page.php" method="get" autocomplete="on">
    Form Element
</form>

				
			

Novalidate Attribute

  • Novalidate Attribute एक Boolean Attribute है।
  • यदि हम Attribute को इस रूप में Apply करते हैं तो यह किसी प्रकार का सत्यापन नहीं करता है और Form Submit कर देता है।
				
					<form action="action_page.php" method="get" novalidate>
    Form Element
</form>

				
			
Facebook
Pinterest
LinkedIn
WhatsApp

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top