From 5a0cb4a9fd868060af3ea0081d5c066d213f9e4b Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Mon, 11 May 2015 08:21:37 +0000
Subject: [PATCH] Fix birthdate format: Forcing DD-MM-YY format was wrong for a
 couple of reasons. Either MM/DD/YY or DD/MM/YY is valid and which is valid is
 based on sysop configuration (European date format enabled or not). I know
 this is kind of lame, but that's the current legacy design of Synchronet.

---
 web/root/ecwebv3/lib/client.js          | 5 +++--
 web/root/ecwebv3/pages/999-newUser.ssjs | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/web/root/ecwebv3/lib/client.js b/web/root/ecwebv3/lib/client.js
index ae281cdcb4..d9f1595988 100644
--- a/web/root/ecwebv3/lib/client.js
+++ b/web/root/ecwebv3/lib/client.js
@@ -331,9 +331,10 @@ var validateNewUserForm = function() {
 				sexCheck++;
 		}
 		if(theForm.elements[e].id == 'birthDate') {
-			if(theForm.elements[e].value.match(/\d\d-\d\d-\d\d/) == null) {
+			if(theForm.elements[e].value.match(/\d\d\/\d\d\/\d\d/) == null) {
 				theForm.elements[e].style.backgroundColor = '#FA5882';
-				document.getElementById(theForm.elements[e].id + 'Error').innerHTML = 'Invalid date (DD-MM-YY)';
+				document.getElementById(theForm.elements[e].id + 'Error').innerHTML = format('Invalid date (%s)'
+					,(system.settings&SYS_EURODATE) ? "DD/MM/YY" : "MM/DD/YY");
 				returnValue = false;
 			} else {
 				theForm.elements[e].style.backgroundColor = '#82FA58';
diff --git a/web/root/ecwebv3/pages/999-newUser.ssjs b/web/root/ecwebv3/pages/999-newUser.ssjs
index 771e2f7e29..a97df4a036 100644
--- a/web/root/ecwebv3/pages/999-newUser.ssjs
+++ b/web/root/ecwebv3/pages/999-newUser.ssjs
@@ -86,8 +86,8 @@ if(http_request.query.hasOwnProperty('font')) {
 	}
 
 	if(system.newuser_questions&UQ_BIRTH) {
-		if(!http_request.query.hasOwnProperty('birthDate') || http_request.query.birthDate.toString().match(/\d\d-\d\d-\d\d/) == null)
-			failString += '- Birth date not provided<br />';
+		if(!http_request.query.hasOwnProperty('birthDate') || http_request.query.birthDate.toString().match(/\d\d\/\d\d\/\d\d/) == null)
+			failString += '- Birthdate not provided<br />';
 		else
 			newUserObject.birthdate = http_request.query.birthDate.toString();
 	}
@@ -159,7 +159,7 @@ if(http_request.query.hasOwnProperty('font')) {
 	if(system.newuser_questions&UQ_SEX)
 		print("Sex: <input class='border font' type='radio' name='sex' id='sex' value='m' />M <input class='border font' type='radio' name='sex' id='sex' value='f' />F <span id='sexError'></span><br /><br />"); // lol
 	if(system.newuser_questions&UQ_BIRTH)
-		print("Birthdate DD-MM-YY:<br /><input class='border font' type='text' size='8' name='birthDate' id='birthDate' /> <span id='birthDateError'></span><br /><br />");
+		print(format("Birthdate (%s):<br /><input class='border font' type='text' size='8' name='birthDate' id='birthDate' /> <span id='birthDateError'></span><br /><br />", (system.settings&SYS_EURODATE) ? "DD/MM/YY" : "MM/DD/YY"));
 	if(system.newuser_questions&UQ_COMPANY)
 		print("Company:<br /><input class='border font' type='text' size='30' name='company' id='company' /> <span id='companyError'></span><br /><br />");
 	if(system.newuser_questions&UQ_NONETMAIL == 0)
-- 
GitLab