I’ve been trying to implement a jQuery function to validate date formats but I have encountered a curious problem. When the number ‘8’ or ‘9’ is contained in the day or month, (ex : 08/06/2011) it says the date is invalid…
A demo is available here :
http://www.geektantra.com/projects/jquery-form-validate/advanced_demo/
Thanks for you help !
When there are problems with the values
08and09, you almost certainly forgot to specify the radix parameter onparseInt().If it’s not specified, it tries to auto-detect the base from the input, and if it finds a leading zero, it tries to parse it as an octal number. For numbers
00to07it’s not an issue, it even evaluates to the same as if it was base-10, but for obvious reasons08and09are invalid octal numbers.To avoid this issue in the future, make sure you always set the radix parameter to force parsing a number as base-10, regardless of the input:
Check out your javascript around line 29 of your HTML file and change it to the following: