Input DatetimeLocal step Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local

Description

The step property sets or gets the step attribute of a local datetime field, which controls the legal number intervals for seconds or milliseconds in a local datetime field.

Example: if step="2", legal numbers could be 0, 2, 4, etc.

You can use step attribute to create a range of legal values.

Set the step property with the following Values

Value Description
number Sets the legal number intervals in the local datetime field.
  • For seconds: Use numbers that will eventually reach "60". Like: "1, "2", "10", "30", etc.
  • For milliseconds: Start with "." and use numbers that eventually will reach "1000". Like ".010", ".050", ".20", etc.

Return Value

A Number, representing the legal number intervals for seconds or milliseconds

The following code shows how to change the legal number intervals for seconds in a local date field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Date: <input type="datetime-local" id="myLocalDate" value="2018-11-16T15:00:33">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from ww  w.j  a v  a  2 s .co m
    document.getElementById("myLocalDate").stepUp();
}
</script>

</body>
</html>

Related Tutorials