News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF 2 - Mandatory birthdate on register with date validation

Started by CrescentEclipse, September 30, 2016, 07:19:36 AM

Previous topic - Next topic

CrescentEclipse

Hello community! :)

Currently I need a bit of help with a modification I want to implement in my forum. But first, the important infos.

SMF version is 2.0.11
I installed some mods, but I think they are not relevant. I will list them anyway.

Additional Instant Messengers 1.0.1
Show Location in Post and PM 1.0 (own mod, not released, just shows the location field in posts and PMs)
Resize Attached Images 2.4.1
Yet Another YouTube BBCode Tag 3.0
Post and PM Inline Attachments 3.17
Default_Membergroup 2.0
Project Snow 1.2

What I want to achieve is a registration page including the birthdate fields. These must be mandatory and the entered date has to be validated (e.g. no empty or invalid dates). In addition it would be nice to temporarily store the entered date, so the user doesn't have to enter the date again if an error occurs.

I used the mod "BirthdayOnRegistration" as a template, but modified and enhanced it. I did my research about the useage of javascript, especialy regarding dates and string to number conversion, and the code SMF uses for the registration process. The result seem to work like intended, but I am unsure if I did everything right. I am not deeply familiar with JS coding and the internals of SMF.

I hope someone can review my code and give me suggestions what I can improve or maybe fix a bug I haven't discovered yet.
I attached the tested mod file.

If everything runs smoothly I will contact the original author of this mod to suggest an update if heis interested.

Thank you very much! :D

lg Cres

CrescentEclipse

Hello again.

Unfortunately, no one answered yet  :(

Did anyone test my code? Is it clean and can I use this without worry?
Please let me know, because I am not sure I did it right. Thanks.

lg Cres

Matthew K.

Checkout "Intuitive Age", a modification I wrote. It'll provide drop downs so you would only need to take account of some months having more/less days than other months which would be significantly easier than parsing users input.

CrescentEclipse

Hi Matthew, thanks for your suggestion, but this does not answer my questions.

You solution is more a cosmetic change, although you are right in case of the safer numerical input.
But I want to validate that the double binary NOT operator redurces everything to a number without any error.
If not, I would have a problem for sure. Otherwise it is simpler to use.

My other problems are the mandatory input and to store the entered values for the registration form, like the username or the mail address. In case of an error or an incomplete form, the user has to correct the input, but do not have to enter the date again. I personally hate to enter things twice if something goes wrong.

My questions are:
Is the double binary NOT operator safe to use in case of string to number conversion?
Can I safely use the function verifyAgree() to catch the invalid or empty date fileds?
Can I safely use $context += array(...) in register.php to cache the date field values?
What about the $regOptions array? How does this work? Is this a better choice?
Is this modification working like I imagine it?

Like I said before I am a beginner in PHP / JS / SMF coding. I thought I would get a bit more help with this :(

CrescentEclipse

Can nobody support me?
I really need help with this :'(
Please...

CrescentEclipse

Hi again.

OKay, what can I do to get more feedback?
Is something missing?
Am I in the wrong board?

???

bestnow

woot+

wanna test it but my forum is sign in with steam account only so have build on website for some information you must fill in before you can visit the forum.

here is my settings site:


CrescentEclipse

Thanks for your share. Unfortunately, such a page is not linked to SMF I guess...

Advertisement: