开发者

date.js simple way to determine if time specified in parse

开发者 https://www.devze.com 2023-04-13 02:13 出处:网络
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 expl

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号