Age Limit?

  • Posts: 127
  • Thank you received: 8
12 years 10 months ago #33503

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.

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 10 months ago #33529

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.

  • Posts: 127
  • Thank you received: 8
12 years 10 months ago #35617

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.

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 10 months ago #35639

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:

JHTML::_('behavior.mootools');
$script='
			do_nothing( 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: 12 years 10 months ago by nicolas.

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

  • Posts: 20
  • Thank you received: 2
12 years 2 months ago #65096

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: 12 years 2 months ago by Taz_1999.

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

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 2 months ago #65098

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.

  • Posts: 20
  • Thank you received: 2
12 years 2 months ago #65111

Is this correct, I seem to be able to register a user three years old.







Added this image too:



This became a textfield?

Attachments:
Last edit: 12 years 2 months ago by Taz_1999.

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

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 2 months ago #65267

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.

  • Posts: 20
  • Thank you received: 2
12 years 2 months ago #65462

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.

  • Posts: 20
  • Thank you received: 2
12 years 2 months ago #65466

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".



Attachments:
Last edit: 12 years 2 months ago by Taz_1999.

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

  • Posts: 20
  • Thank you received: 2
12 years 2 months ago #65472

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: 12 years 2 months ago by Taz_1999.

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

  • Posts: 82818
  • Thank you received: 13362
  • MODERATOR
12 years 2 months ago #65631

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.

  • Posts: 20
  • Thank you received: 2
12 years 2 months ago #65634

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.097 seconds
Powered by Kunena Forum