VBScript IsDate function
IsDate function returns indicates whether the calculation expression to a Boolean value date. If the expression is a date or can be converted to a date, it returns True. Otherwise, it returns False.
Note: IsDate function uses local setting to detect whether a string can be converted to a date (in all languages, "January" is not a month).
grammar
IsDate(expression)
参数 | 描述 |
---|---|
expression | 必需。要计算的表达式。 |
Example 1
Legitimate Date:
<script type="text/vbscript">
document.write(IsDate("April 22, 1947"))
document.write("<br />")
document.write(IsDate(#01/31/10#))
</script>
document.write(IsDate("April 22, 1947"))
document.write("<br />")
document.write(IsDate(#01/31/10#))
</script>
Examples of the above output:
True
True
True
try it"
Example 2
Illegal date:
<script type="text/vbscript">
document.write(IsDate("#01/31/10#"))
document.write("<br />")
document.write(IsDate("52/17/2010"))
document.write("<br />")
document.write(IsDate("Hello World!"))
</script>
document.write(IsDate("#01/31/10#"))
document.write("<br />")
document.write(IsDate("52/17/2010"))
document.write("<br />")
document.write(IsDate("Hello World!"))
</script>
Examples of the above output:
False
False
False
False
False
try it"
Complete VBScript Reference