[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc dateformat.js
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] property/inc dateformat.js |
Date: |
Mon, 06 Feb 2006 21:28:44 +0000 |
CVSROOT: /sources/phpgroupware
Module name: property
Branch:
Changes by: Sigurd Nes <address@hidden> 06/02/06 21:28:44
Modified files:
inc : dateformat.js
Log message:
no message
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/dateformat.js.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: property/inc/dateformat.js
diff -u property/inc/dateformat.js:1.2 property/inc/dateformat.js:1.3
--- property/inc/dateformat.js:1.2 Wed Jun 2 18:54:28 2004
+++ property/inc/dateformat.js Mon Feb 6 21:28:44 2006
@@ -1,26 +1,10 @@
-//Copyright (C) 2002,2003 Richard Gorremans
-//This library is free software; you can redistribute it and/or
-//modify it under the terms of the GNU Lesser General Public
-//License as published by the Free Software Foundation; either
-//version 2.1 of the License, or (at your option) any later version.
-
-//This library is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-//Lesser General Public License for more details.
-
-//You should have received a copy of the GNU Lesser General Public
-//License along with this library; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-<!-- Original: Richard Gorremans (address@hidden) -->
-<!-- Updates: www.spiritwolfx.com -->
-<!-- Begin
+<!-- Original: Richard Gorremans (address@hidden) ==>
+<!-- Updates: www.spiritwolfx.com
// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
-var strSeperator = "/";
-// If you are using any Java validation on the back side you will want to use
the / because
+var strSeperator = "/";
+// If you are using any Java validation on the back side you will want to use
the / because
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
@@ -34,21 +18,21 @@
var err = 0; // Set the error code to a default of zero
-if(navigator.appName == "Netscape")
+if(navigator.appName == "Netscape")
{
- if (navigator.appVersion < "5")
+ if (navigator.appVersion < "5")
{
isNav4 = true;
isNav5 = false;
}
else
- if (navigator.appVersion > "4")
+ if (navigator.appVersion > "4")
{
isNav4 = false;
isNav5 = true;
}
}
-else
+else
{
isIE4 = true;
}
@@ -59,11 +43,10 @@
vDateType = dateType;
mDateValue = vDateValue;
-
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
-// dateCheck
+// dateCheck
// True = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
@@ -71,7 +54,7 @@
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
-
+
//Enter a tilde sign for the first number and you can check the variable
information.
if (vDateValue == "~")
{
@@ -80,9 +63,9 @@
vDateName.focus();
return true;
}
-
+
var whichCode = (window.Event) ? e.which : e.keyCode;
-
+
// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4)
@@ -90,10 +73,10 @@
if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
return true;
}
-
+
//Eliminate all the ASCII codes that are not valid
var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
- if (alphaCheck.indexOf(vDateValue) >= 1)
+ if (alphaCheck.indexOf(vDateValue) >= 1)
{
if (isNav4)
{
@@ -106,19 +89,19 @@
{
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
- }
+ }
}
if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no
value
return false;
- else
+ else
{
//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
-
- var strCheck =
'47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
- if (strCheck.indexOf(whichCode) != -1)
+
+ var strCheck =
'undefined,0,47,48,49,50,51,52,53,54,55,56,57,58,59,65,95,96,97,98,99,100,101,102,103,104,105';
+ if (strCheck.indexOf(whichCode) != -1)
{
- if (isNav4)
+ if (isNav4)
{
if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length ==
7 && dateCheck)) && (vDateValue.length >=1))
{
@@ -128,19 +111,19 @@
vDateName.select();
return false;
}
- if (vDateValue.length == 6 && dateCheck)
+ if (vDateValue.length == 6 && dateCheck)
{
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
-
+
//Turn a two digit year into a 4 digit year
- if (mYear.length == 2 && vYearType == 4)
+ if (mYear.length == 2 && vYearType == 4)
{
var mToday = new Date();
-
+
//If the year is greater than 30 years from now use 19,
otherwise use 20
- var checkYear = mToday.getFullYear() + 30;
+ var checkYear = mToday.getFullYear() + 30;
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
@@ -148,8 +131,8 @@
mYear = '20' + mYear;
}
var vDateValueCheck =
mMonth+strSeperator+mDay+strSeperator+mYear;
-
- if (!dateValid(vDateValueCheck))
+
+ if (!dateValid(vDateValueCheck))
{
alert("Invalid Date\nPlease Re-Enter");
vDateName.value = "";
@@ -159,14 +142,14 @@
}
vDateName.value = vDateValueCheck;
return true;
-
+
}
else
{
// Reformat the date for validation and set date type to a 1
-
-
- if (vDateValue.length >= 8 && dateCheck)
+
+
+ if (vDateValue.length >= 8 && dateCheck)
{
if (vDateType == 1) // mmddyyyy
{
@@ -189,15 +172,15 @@
var mYear = vDateName.value.substr(4,4)
vDateName.value =
mDay+strSeperator+mMonth+strSeperator+mYear;
}
-
+
//Create a temporary variable for storing the DateType and
change
//the DateType to a 1 for validation.
-
+
var vDateTypeTemp = vDateType;
vDateType = 1;
var vDateValueCheck =
mMonth+strSeperator+mDay+strSeperator+mYear;
-
- if (!dateValid(vDateValueCheck))
+
+ if (!dateValid(vDateValueCheck))
{
alert("Invalid Date\nPlease Re-Enter");
vDateType = vDateTypeTemp;
@@ -222,7 +205,7 @@
}
}
}
- else
+ else
{
// Non isNav Check
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length ==
9 && dateCheck)) && (vDateValue.length >=1))
@@ -232,16 +215,16 @@
vDateName.focus();
return true;
}
-
+
// Reformat date to format that can be validated. mm/dd/yyyy
-
-
- if (vDateValue.length >= 8 && dateCheck)
+
+
+ if (vDateValue.length >= 8 && dateCheck)
{
-
+
// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will
recognize.
-
+
if (vDateType == 1) // mm/dd/yyyy
{
var mMonth = vDateName.value.substr(0,2);
@@ -270,44 +253,44 @@
return true;
}
}
-
+
// Create temp. variable for storing the current vDateType
var vDateTypeTemp = vDateType;
-
+
// Change vDateType to a 1 for standard date format for
validation
// Type will be changed back when validation is completed.
vDateType = 1;
-
+
// Store reformatted date to new variable for validation.
var vDateValueCheck =
mMonth+strSeperator+mDay+strSeperator+mYear;
-
- if (mYear.length == 2 && vYearType == 4 && dateCheck)
+
+ if (mYear.length == 2 && vYearType == 4 && dateCheck)
{
-
+
//Turn a two digit year into a 4 digit year
var mToday = new Date();
-
+
//If the year is greater than 30 years from now use 19,
otherwise use 20
- var checkYear = mToday.getFullYear() + 30;
+ var checkYear = mToday.getFullYear() + 30;
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
vDateValueCheck =
mMonth+strSeperator+mDay+strSeperator+mYear;
-
+
// Store the new value back to the field. This function will
// not work with date type of 2 since the year is entered
first.
-
+
if (vDateTypeTemp == 1) // mm/dd/yyyy
vDateName.value =
mMonth+strSeperator+mDay+strSeperator+mYear;
if (vDateTypeTemp == 3) // dd/mm/yyyy
vDateName.value =
mDay+strSeperator+mMonth+strSeperator+mYear;
- }
-
-
- if (!dateValid(vDateValueCheck))
+ }
+
+
+ if (!dateValid(vDateValueCheck))
{
alert("Invalid Date\nPlease Re-Enter");
vDateType = vDateTypeTemp;
@@ -317,40 +300,40 @@
}
vDateType = vDateTypeTemp;
return true;
-
+
}
else
{
-
+
if (vDateType == 1)
{
- if (vDateValue.length == 2)
+ if (vDateValue.length == 2)
{
vDateName.value = vDateValue+strSeperator;
}
- if (vDateValue.length == 5)
+ if (vDateValue.length == 5)
{
vDateName.value = vDateValue+strSeperator;
}
}
if (vDateType == 2)
{
- if (vDateValue.length == 4)
+ if (vDateValue.length == 4)
{
vDateName.value = vDateValue+strSeperator;
}
- if (vDateValue.length == 7)
+ if (vDateValue.length == 7)
{
vDateName.value = vDateValue+strSeperator;
}
- }
+ }
if (vDateType == 3)
{
- if (vDateValue.length == 2)
+ if (vDateValue.length == 2)
{
vDateName.value = vDateValue+strSeperator;
}
- if (vDateValue.length == 5)
+ if (vDateValue.length == 5)
{
vDateName.value = vDateValue+strSeperator;
}
@@ -358,12 +341,12 @@
return true;
}
}
- if (vDateValue.length == 10 && dateCheck)
+ if (vDateValue.length == 10 && dateCheck)
{
- if (!dateValid(vDateName))
+ if (!dateValid(vDateName))
{
// Un-comment the next line of code for debugging the dateValid() function
error messages
-// alert(err);
+// alert(err);
alert("Invalid Date\nPlease Re-Enter");
vDateName.focus();
vDateName.select();
@@ -371,7 +354,7 @@
}
return false;
}
- else
+ else
{
// If the value is not in the string return the string minus the last
// key entered.
@@ -384,7 +367,9 @@
}
else
{
- vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
+ if (whichCode != 16){
+ vDateName.value = vDateName.value.substr(0,
(vDateValue.length-1));
+ }
return false;
}
}
@@ -419,23 +404,23 @@
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
-
+
//strDate = datefield.value;
strDate = objName;
-
+
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length;
intElementNr++) {
- if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1)
+ if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1)
{
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
- if (strDateArray.length != 3)
+ if (strDateArray.length != 3)
{
err = 1;
return false;
}
- else
+ else
{
strDay = strDateArray[0];
strMonth = strDateArray[1];
@@ -463,7 +448,7 @@
err = 2;
return false;
}
-
+
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
@@ -525,4 +510,4 @@
}
return false;
}
-// End -->
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc dateformat.js,
Sigurd Nes <=