Not Parsing Date Correctly (Leading 0s)
-
I was running into an issue on Firefox (possibly other browsers as well) where if the user entered a month or day with a leading 0 (such as “05”), the JS would then append another 0 to the beginning (making it “005”). This would cause the age verification to fail, even if the age entered was over the limit.
To fix this, I changed the parseDob function in the verifier.js file to the following:
this.parseDob = function(){ var wrapper = jQuery('#taseav-age-verify'); var month = parseInt( wrapper.find('input[name="month"]').val() ); var day = parseInt( wrapper.find('input[name="day"]').val() ); var year = parseInt( wrapper.find('input[name="year"]').val() ); if(month < 10){ month = "0" + month; } if(day < 10){ day = "0" + day; } return year + "-" + month + "-" + day; }
Posting this in case anyone else runs into this issue.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Not Parsing Date Correctly (Leading 0s)’ is closed to new replies.