fareedreg Posted January 12, 2010 Share Posted January 12, 2010 {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 function validateDate(fld) \{\par var RegExPattern = /^((((0?[1-9]|[12]\\d|3[01])[\\.\\-\\/](0?[13578]|1[02])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0?[1-9]|[12]\\d|30)[\\.\\-\\/](0?[13456789]|1[012])[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0?[1-9]|1\\d|2[0-8])[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?\\d\{2\}))|(29[\\.\\-\\/]0?2[\\.\\-\\/]((1[6-9]|[2-9]\\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0[1-9]|[12]\\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\\d)?\\d\{2\}))|((0[1-9]|1\\d|2[0-8])02((1[6-9]|[2-9]\\d)?\\d\{2\}))|(2902((1[6-9]|[2-9]\\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;\par var errorMessage = 'Please enter valid date as month, day, and four digit year.\\nYou may use a slash, hyphen or period to separate the values.\\nThe date must be a real date. 30/2/2000 would not be accepted.\\nFormay dd/mm/yyyy.';\par if ((fld.value.match(RegExPattern)) && (fld.value!='')) \{\par alert('Date is OK'); \par \} else \{\par alert(errorMessage);\par fld.focus();\par \} \par \}\par \par } This is my java script for validation of date dd/mm/yyyy i m calling it from my html form like this <td><input name="txtissue" type="text" id="txtissue" size="10" maxlength="10"/> <script language="JavaScript" type="text/javascript"> validateDate("txtissue"); </script> </body> </html> showing unexpected error why Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.