Input Types
Next ❯Form Attributes
Input Type | Description |
---|---|
text | Single line text field |
password | Single line Password Field (Mainly used for sensitive information) |
submit | Used to submit your form automatically by just clicking on it |
reset | To reset the form fields |
radio | Used when one option is required out of many options |
checkbox | Used when more than one option is required to be selected |
button | To create button from this option also |
hidden | Used when any fixed data has to be send on the server |
file | Used to upload any file to the server |
image | To create image type button |
- All the codes below are being used inside
<body>
tag - Alert! Your output appearance will be different because of not using CSS. So, Don't get confuse
- label_outlineInput type "text"
OUTPUT<form> First name:<br> <input type="text" name="first_name"><br> Last name:<br> <input type="text" name="last_name"> </form>
- label_outlineInput type "password"
OUTPUT<form> User name:<br> <input type="text" name="username"><br> User password:<br> <input type="password" name="pass"> </form>
- label_outlineInput type "submit"
OUTPUT<form action="action_page.php"> 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"> </form>
- This is just a sample example, to see the "action_page.php" file check out Form action section
- label_outlineInput type "reset"
OUTPUT<form action="action_page.php"> 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"> </form>
- Just Enter anything inside input fields and then after press Reset button
- label_outlineInput type "hidden"
OUTPUT<form> User name:<br> <input type="text" name="username"><br> User password:<br> <input type="password" name="pass"> <input type="hidden" name="key" value="Kuytsdvnvkdnfknkvfdn===" /> </form>
- "Hidden" type value is already set by the programmer which is submitted along with the user information for some reasons. (like authentication keys used for authentication)
- It's not appear or visible in the page
- label_outlineInput type "radio"
OUTPUT<form> Gender: <input type="radio" name="gender" value="male" checked> Male <input type="radio" name="gender" value="female"> Female </form>
- label_outlineInput type "checkbox"
OUTPUT<form> Subjects<br> <input type="checkbox" name="maths" value="maths"> Maths<br> <input type="checkbox" name="history" value="history"> History </form>
- label_outlineInput type "button"
OUTPUT<input type="button" onclick="alert('Hello I am button!')" value="Button!">
- label_outlineInput type "file"
OUTPUT<form> <!--To accept All file types--> Any File: <input type="file" name="fileupload1"/><br> <!--To accept Specific file types--> Image File: <input type="file" name="fileupload" accept="image/*"/><br> <!--To accept multiple files--> Multiple Files: <input type="file" name="fileupload2" multiple/> </form>
- label_outlineInput type "image"
OUTPUT<form> <input type="image" name="imagebutton" src="images/imageFile.png" /> </form>
- here, the above image act as a image button
Browsers Supports
Safari | Microsoft Edge | Mozilla Firefox | Chrome | Opera Mini |
Click on the above icon to see the name of the browser !
- Tips! Always try to use latest version of browser
❮ Prev Form Elements
Next ❯Form Attributes