Check date format in JavaScript
问题 I would like to check if the date format is (dd/mm/yyyy) before the post is made in a JavaScript (jQuery). How could I achieve that? 回答1: You can use a regex: /^\d{2}\/\d{2}\/\d{4}$/.test(str) Of course this will not check for a valid date, but in that case you can always let your server-side code throw an error. If you want more client-side validation have a look at Javascript: how to validate dates in format MM-DD-YYYY?; it is easy to adapt to your format. 回答2: i think that would be very