Mandala Posted November 2, 2010 Share Posted November 2, 2010 Hi,Apologies if this is a stupid question. Due to the nature of our business, we can not have anyone under the age of 18 purchasing products. Is there a way in PrestaShop 1.3.1 to deny registration to people who put in a date that states they are under the age of 18?Thank you. Link to comment Share on other sites More sharing options...
Mandala Posted November 4, 2010 Author Share Posted November 4, 2010 Just a quick bump, really looking for an answer on this one - any help would be appreciatedThank you! Link to comment Share on other sites More sharing options...
rocky Posted November 5, 2010 Share Posted November 5, 2010 I suggest that you use Javascript to compare the birthday to the current date. Add something like this in authentication.tpl: <script language="javascript"> function checkAge() { /* the minumum age you want to allow in */ var min_age = 18; /* change "age_form" to whatever your form has for a name="..." */ var year = parseInt($('#years').value); var month = parseInt($('#months').value); var day = parseInt($('#days').value); var theirDate = new Date((year + min_age), month, day); var today = new Date; if ((today.getTime() - theirDate.getTime()) < 0) { alert("You are too young to enter this site!"); return false; } else return true; } </script> then change line 224 of authentication.tpl: <input type="submit" name="submitAccount" id="submitAccount" value="{l s='Register'}" class="exclusive" /> Add onclick="return checkAge()" to the button (with straight quotes, not angle quotes). It's annoying how the forums automatically delete onclick events from all posted code. Link to comment Share on other sites More sharing options...
Mandala Posted November 5, 2010 Author Share Posted November 5, 2010 Thanks!I'll give this a try Link to comment Share on other sites More sharing options...
Mandala Posted November 5, 2010 Author Share Posted November 5, 2010 Sorry about this, but where does the onclick go to? And do I have to place the large chunk of code in any particular area of the tpl?Thanks Link to comment Share on other sites More sharing options...
rocky Posted November 6, 2010 Share Posted November 6, 2010 Add the onclick event before the /> at the end of the line.You can put the Javascript anywhere in the TPL file. Link to comment Share on other sites More sharing options...
babyewok Posted June 15, 2011 Share Posted June 15, 2011 Hi rocky - I'm trying to implement this on v.1.4 and nothing seems to happen even if I put 2001 as the year of birth - is there something I need to change for it to work on v 1.4? Link to comment Share on other sites More sharing options...
babyewok Posted June 15, 2011 Share Posted June 15, 2011 hmm, maybe it has something to do with where you say "change "age_form" to whatever your form has for a name="..." "...I can't see age_form referrenced in your javascript Link to comment Share on other sites More sharing options...
babyewok Posted June 17, 2011 Share Posted June 17, 2011 I managed to get this working by changing var year = parseInt($('#years').value); var month = parseInt($('#months').value); var day = parseInt($('#days').value); to var year = parseInt(document.forms["account-creation_form"]["years"].value); var month = parseInt(document.forms["account-creation_form"]["months"].value); var day = parseInt(document.forms["account-creation_form"]["days"].value); and adding name="account-creation_form" to the necessary form Link to comment Share on other sites More sharing options...
redon.ecreeds Posted April 24, 2013 Share Posted April 24, 2013 Hi, i have use this code dob is(23-04-1995) it is firing that alert message but when i differentiate the age between filled value and current date.this is giving positive value Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now