Click here to Skip to main content
15,886,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends i want to Check weather the entered date is in "dd-mmm-yyyy" format using Javascript, IF any one knows kindly Help me......


Thanking you in Advance
Sushil Dharmar
Posted
Comments
Herman<T>.Instance 31-Jul-11 16:05pm    
google and find:
http://stackoverflow.com/questions/3858413/regular-expression-for-dd-mmm-yyyy-and-dd-mmm for the format
and
http://www.geekzilla.co.uk/View653502BD-00B7-4012-9786-F941208F5F0C.htm
for how to use regular expressions in javascript

Here[^]
 
Share this answer
 
XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
        <title></title>
        <script type="text/javascript">
            function IsValidDate(myDate) {
                var filter = /^([012]?\d|3[01])-([Jj][Aa][Nn]|[Ff][Ee][bB]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][u]l|[aA][Uu][gG]|[Ss][eE][pP]|[oO][Cc]|[Nn][oO][Vv]|[Dd][Ee][Cc])-(19|20)\d\d$/
                                return filter.test(myDate);
            }
            function test() {
                var txtTest = document.getElementById('txtTest');
                var isValid = IsValidDate(txtTest.value);
                if (isValid) {
                    alert('Correct format');
                }
                else {
                    alert('Incorrect format');
                }
                return isValid
            }


        </script>
</head>
<body>
        <input id="txtTest" type="text" />
        <input id="btnTest" type="button" value="button" onclick="return test();"/>




</body>


</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900