date.js simple way to determine if time specified in parse
Using date.js's Date.parse
what's the simplest way to determine whether a user input string, e.g. 'oct 31 12am' vs just 'o开发者_Go百科ct 31', includes a time value, i.e. whether a time was explicitly specified or not.
use regular expression to check if the user has entered am or pm, if not give them a message saying it must be included
<script type="text/javascript">
var str= $("#date_input").val;
var patt1=/am|pm/gi;
if (!str.match(patt1)){
$("#message").text("you must include a time in either 'am' or 'pm' format");
}
</script>
精彩评论