Age Check

  • temills
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 5 months ago #70126 by temills
Age Check was created by temills
Hi Tran,

Our competition events group individuals by age category. During registration the registrant selects their competition category and enters his/her year of birth, as the competition age is based on age on Dec 31 of the competition year. We use a custom javascript to check by using Current Year - Year of Birth when the user completes those items on the registration form. This works fine except when the tournament year is not the current year (for instance, registration in October 2015 for a Jan 2016 tournament). We would like to reference the year of the tournament start date in the javascript? Can this be done? If so, please advise. If it helps, I've attached a file with the javascript that we use.

Thanks,
Tem

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

More
10 years 5 months ago #70144 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Age Check
Hi Tem

Means you want to present year of the event in javascript ? If so, on what page you want to present this data ? Maybe you want the year available in a javascript variable?

Tuan

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

  • temills
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 5 months ago #70162 by temills
Replied by temills on topic Age Check
Hi Tuan,

Yes, we want the year of the event available in a javascript variable on the registration form page , i.e., when the user is registering for the event. The variable would replace the CurrentYear variable in the javascript file I sent. Can we do that?

Tem

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

More
10 years 5 months ago #70163 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Age Check
The javascript file was not uploaded, I could not see your code. Could you please upload the file components/com_eventbooking/view/register/html.php here ? Please zip the file before uploading, otherwise, it won't be uploaded

Tuan

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

  • temills
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 5 months ago #70165 by temills
Replied by temills on topic Age Check
Here's both the html.php and the javascript

File Attachment:

File Name: AgeCategor...k_v2.zip
File Size:1.17 KB


File Attachment:

File Name: html.zip
File Size:3.67 KB

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

More
10 years 5 months ago #70186 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Age Check
Hi Tem

Sorry, I am too busy and could not read the validation code. You can get this file, unzip and upload it to components/com_eventbooking/view/register folder of your site.

Run it and you will see a javascript variable called eventYear available for you to use. If you look at the file, you will see that it is generated by this code:
Code:
// Customization to add javascript variable store event year $eventYear = JHtml::_('date', $event->event_date, 'Y', null); $document = JFactory::getDocument(); $document->addScriptDeclaration(" var eventYear = $eventYear; "); //End Customization

Hope it is a good start for you to work on the customization

Tuan

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

  • temills
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 5 months ago #70230 by temills
Replied by temills on topic Age Check
No file attached

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

More
10 years 5 months ago #70237 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Age Check
Hmm. Seems it was not uploaded for some reasons. Please get the file here

Tuan

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

  • temills
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 5 months ago #70291 by temills
Replied by temills on topic Age Check
Hi Tuan,

Worked like a charm.

As always, thanks for your outstanding support,

Tem

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

More
10 years 5 months ago #70293 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Age Check
OK Tem. Thanks for confirming.

Tuan

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

Moderators: Tuan Pham Ngoc