
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Time required Property
The HTML DOM Input Time required property determines whether Input Time is compulsory to set or not.
Syntax
Following is the syntax −
- Returning boolean value - true/false
inputTimeObject.required
- Setting required to booleanValue
inputTimeObject.required = booleanValue
Boolean Values
Here, “booleanValue” can be the following −
booleanValue | Details |
---|---|
true | It is compulsory to set the time field to submit form. |
false | It is the default value and to set time field is not compulsory. |
Example
Let us see an example of Input Time required property −
<!DOCTYPE html> <html> <head> <title>Input Time required</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>Time-required</legend> <label for="TimeSelect">Appointment with Supervisor:</label> <input type="time" id="TimeSelect" required> <input type="button" onclick="fixMeeting()" value="Fix Meeting"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputTime = document.getElementById("TimeSelect"); function fixMeeting() { if(inputTime.required === true && inputTime.value === '') divDisplay.textContent = 'The meeting time is required'; else divDisplay.textContent = 'The meeting time fixed at: '+inputTime.value; } </script> </body> </html>
Output
This will produce the following output −
Clicking ‘Fix Meeting’ button with empty time field −
After clicking ‘Fix Meeting’’ button with time field set −
- Related Articles
- HTML DOM Input URL required Property
- HTML DOM Input Week required Property
- HTML DOM Input Search required property
- HTML DOM Input Text required property
- HTML DOM Input Radio required property
- HTML DOM Input Password required property
- HTML DOM Input FileUpload required Property
- HTML DOM Input Month required Property
- HTML DOM Input Number required Property
- HTML DOM Input Checkbox required Property
- HTML DOM Input Date required Property
- HTML DOM Input Datetime required Property
- HTML DOM Input DatetimeLocal required Property
- HTML DOM Input Email required Property
- HTML DOM Input Time type Property

Advertisements