Skip to main content

Age Limit?

More
14 years 9 months ago #33503 by twhcreations
Age Limit? was created by twhcreations
I have a project i am working on, its for a winery to sell online they must record the clients age and record it against the sale.

Does anyone know how this could be done?
mcgrathwines.com.au/index.php/online-shop

Please Log in or Create an account to join the conversation.

More
14 years 9 months ago #33529 by nicolas
Replied by nicolas on topic Re: Age Limit?
Hi,

You can create custom fields via the menu Display->Custom fields to ask more information to your customers.
If you create custom fields of the table "order", it will display on the checkout as additional information.
If it's of the table "address", it will be in the address form. If it's of the table "user", it will be as user information.

Please Log in or Create an account to join the conversation.

More
14 years 8 months ago #35617 by twhcreations
Replied by twhcreations on topic Re: Age Limit?
Is there an easy way to question this entry and confirm that the age entered is over 18 years of age?

Please Log in or Create an account to join the conversation.

More
14 years 8 months ago - 14 years 8 months ago #35639 by nicolas
Replied by nicolas on topic Re: Age Limit?
You could do that by adding some javascript in the file "registration" of the view "user" via the menu Display->Views.
Suppose that your custom field is called "user_age", you would have that:
Code:
JHTML::_('behavior.mootools'); $script=' window.addEvent(\'domready\', function() { $(\'user_age\').addEvent(\'change\',function(){ if(parseInt(this.value)<19){ alert(\'You must be over 18 years old\'); this.value = \'\'; } }); }); '; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($script);
Last edit: 14 years 8 months ago by nicolas.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago - 14 years 3 weeks ago #65096 by Taz_1999
Replied by Taz_1999 on topic Re: Age Limit?
I'm having trouble figuring out where in the file I should place this. Could someone help me?

(It's not at the end of the file anyways, just tried that.) :)
Last edit: 14 years 3 weeks ago by Taz_1999.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago #65098 by nicolas
Replied by nicolas on topic Re: Age Limit?
It should be added after the first <?php tag of the file.
The following user(s) said Thank You: Taz_1999

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago - 14 years 3 weeks ago #65111 by Taz_1999
Replied by Taz_1999 on topic Re: Age Limit?
Is this correct, I seem to be able to register a user three years old.







Added this image too:



This became a textfield?
Last edit: 14 years 3 weeks ago by Taz_1999.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago #65267 by nicolas
Replied by nicolas on topic Re: Age Limit?
It sounds correct yes.

Could you give a link to that so that we can see what you have ?

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago #65462 by Taz_1999
Replied by Taz_1999 on topic Re: Age Limit?
Sorry no link. It's not open to the public yet.

Still doesn't work. Don't know why.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago - 14 years 3 weeks ago #65466 by Taz_1999
Replied by Taz_1999 on topic Re: Age Limit?
Two more pictures, the registration field with the date field, and the date I'm using to register. (The screenshot only shows this date filled in the form but before I go on I fill in all fields correctly, all of it). There are no errors on submit, I get: Thank you for registring and a confirmation email to the mail adress I used.

Also a screenshot of inside edit fields. I changed "Only old dates" and set it to "All dates"/"Alla datum".



Last edit: 14 years 3 weeks ago by Taz_1999.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago - 14 years 3 weeks ago #65472 by Taz_1999
Replied by Taz_1999 on topic Re: Age Limit?
Also, in Sweden you write your Personal identity number as:

YYYYMMDD-NNNZ

The Z is a checkssumnumber.

What codechanges would I need to do to convert YYYYMMDD to a regular date and then use that date to check the age limit?

I would also change the field length to 13 and the name to user_personal_identity_number and the type to text.
Last edit: 14 years 3 weeks ago by Taz_1999.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago #65631 by nicolas
Replied by nicolas on topic Re: Age Limit?
We would need to look at the HTML/javascript of your page with firebug in order to say what could be wrong with your changes as what you showed so far is ok.
That's why I asked for a link. A screenshot won't do.

But I think you didn't understand the initial messages of that thread.
You have to create a custom field of the type "dropdown" with the age of the person, not with the birthday. Otherwise, the javascript I gave you won't work.

You can't change the name field column name. You can however create a new field with that column name and unpublish the default name field.

If you want to check the age based on the personal identidy number, that will require more complex javascript.
You would have first to cut the string and then compare the year.

This is already far outside regular support, I would recommend that you seek the help of a developer if you want to do these customization or stick with the initial customization of having a dropdown where the user select his age.

Please Log in or Create an account to join the conversation.

More
14 years 3 weeks ago #65634 by Taz_1999
Replied by Taz_1999 on topic Re: Age Limit?
You are correct in everything. I missed a part in the original thread that the field was not a date field it was supposed to be a number, selectable in a menu.

When I tried entering just 18 in the field instead of 2010-12-20 (which is way larger than 19), then I got the expected behaviour. So it works as advertised, even with a text field instead of a menu. :)

I also understand about the limits of regular support, and would like to say thank you for the help! I will ask a friend with the rest. Maybe that will result in some code I can post here for others with the same problem.
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.235 seconds
Powered by Kunena Forum