I cant see why this wont work:
(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/(19|20)\d\d [012]\d:[0-5]\d
I am attempting to make sure that the date/time is formatted this way:
mm/dd/yyyy hh:mm
Any help would be most appreciated.
date / time regex
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
... (beats trent2800 with a rank kipper) ... 
Sorry trent - you might find vbscript knowledge a little thin around here, I know I never did anything of consequence in it
It works in javascript:
Anyone else?
Sorry trent - you might find vbscript knowledge a little thin around here, I know I never did anything of consequence in it
It works in javascript:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="Author" content="Kieran Huggins - http://kieran.ca" />
<link rel="stylesheet" href="" media="screen" />
<style type="text/css">input{width: 400px;}</style>
<script type="text/javascript">
function validate(input){
var rx = document.getElementById('regex');
var dt = document.getElementById('date');
var op = document.getElementById('output');
if(dt.value.match(rx.value)){
op.value='match';
}else{
op.value='';
}
}
</script>
</head>
<body onload="validate()">
<input id="date" type="text" value="12/08/1979 15:36" onkeyup="validate()"/><br/>
<input id="regex" type="text" value="(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/(19|20)\d\d [012]\d:[0-5]\d" onkeyup="validate()"/><br/>
<input id="output" type="text" style="color: green;"/>
</body>
</html>- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: