[TEP-COMMIT] [CVS catalog] update the javascript functions for the new date pull down menu function
anonymous-OfajU3CKLf1/[email protected] 16 Apr 2004 14:14:35 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit in catalog/catalog/includes on MAIN
form_check.js.php -3 1.9 -> 1.10
general.js +17 -144 1.3 -> 1.4
+17 -147
2 modified files
update the javascript functions for the new date pull down menu function
----------
catalog /catalog /includes
form_check.js.php 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- form_check.js.php 2003/05/19 19:50:14 1.9
+++ form_check.js.php 2004/04/16 14:14:34 1.10
@@ -106,9 +106,6 @@
check_input("firstname", <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>, "<?php echo ENTRY_FIRST_NAME_ERROR; ?>");
check_input("lastname", <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>, "<?php echo ENTRY_LAST_NAME_ERROR; ?>");
-
-<?php if (ACCOUNT_DOB == 'true') echo ' check_input("dob", ' . ENTRY_DOB_MIN_LENGTH . ', "' . ENTRY_DATE_OF_BIRTH_ERROR . '");' . "\n"; ?>
-
check_input("email_address", <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>, "<?php echo ENTRY_EMAIL_ADDRESS_ERROR; ?>");
check_input("street_address", <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>, "<?php echo ENTRY_STREET_ADDRESS_ERROR; ?>");
check_input("postcode", <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>, "<?php echo ENTRY_POST_CODE_ERROR; ?>");
----------
catalog /catalog /includes
general.js 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- general.js 2003/02/10 22:30:55 1.3
+++ general.js 2004/04/16 14:14:34 1.4
@@ -4,7 +4,7 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2003 osCommerce
+ Copyright (c) 2004 osCommerce
Released under the GNU General Public License
*/
@@ -21,7 +21,7 @@
}
var TargetForm = document.forms[target];
-
+
for (i=0; i<TargetForm.length; i++) {
if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
TargetForm.elements[i].focus();
@@ -34,157 +34,30 @@
}
}
}
-
-function RemoveFormatString(TargetElement, FormatString) {
- if (TargetElement.value == FormatString) {
- TargetElement.value = "";
- }
-
- TargetElement.select();
-}
-
-function CheckDateRange(from, to) {
- if (Date.parse(from.value) <= Date.parse(to.value)) {
- return true;
- } else {
- return false;
- }
-}
-
-function IsValidDate(DateToCheck, FormatString) {
- var strDateToCheck;
- var strDateToCheckArray;
- var strFormatArray;
- var strFormatString;
- var strDay;
- var strMonth;
- var strYear;
- var intday;
- var intMonth;
- var intYear;
- var intDateSeparatorIdx = -1;
- var intFormatSeparatorIdx = -1;
- var strSeparatorArray = new Array("-"," ","/",".");
- var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
- var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
-
- strDateToCheck = DateToCheck.toLowerCase();
- strFormatString = FormatString.toLowerCase();
-
- if (strDateToCheck.length != strFormatString.length) {
- return false;
- }
-
- for (i=0; i<strSeparatorArray.length; i++) {
- if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
- intFormatSeparatorIdx = i;
- break;
- }
- }
-
- for (i=0; i<strSeparatorArray.length; i++) {
- if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
- intDateSeparatorIdx = i;
- break;
- }
- }
-
- if (intDateSeparatorIdx != intFormatSeparatorIdx) {
- return false;
- }
-
- if (intDateSeparatorIdx != -1) {
- strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
- if (strFormatArray.length != 3) {
- return false;
- }
-
- strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
- if (strDateToCheckArray.length != 3) {
- return false;
- }
- for (i=0; i<strFormatArray.length; i++) {
- if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
- strMonth = strDateToCheckArray[i];
- }
+function updateDatePullDownMenu(objForm, fieldName) {
+ var pdmDays = fieldName + "_days";
+ var pdmMonths = fieldName + "_months";
+ var pdmYears = fieldName + "_years";
- if (strFormatArray[i] == 'dd') {
- strDay = strDateToCheckArray[i];
- }
+ time = new Date(objForm[pdmYears].options[objForm[pdmYears].selectedIndex].text, objForm[pdmMonths].options[objForm[pdmMonths].selectedIndex].value, 1);
- if (strFormatArray[i] == 'yyyy') {
- strYear = strDateToCheckArray[i];
- }
- }
- } else {
- if (FormatString.length > 7) {
- if (strFormatString.indexOf('mmm') == -1) {
- strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
- } else {
- strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
- }
+ time = new Date(time - 86400000);
- strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
- strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
- } else {
- return false;
- }
- }
+ var selectedDay = objForm[pdmDays].options[objForm[pdmDays].selectedIndex].text;
+ var daysInMonth = time.getDate();
- if (strYear.length != 4) {
- return false;
+ for (var i=0; i<objForm[pdmDays].length; i++) {
+ objForm[pdmDays].options[0] = null;
}
- intday = parseInt(strDay, 10);
- if (isNaN(intday)) {
- return false;
- }
- if (intday < 1) {
- return false;
+ for (var i=0; i<daysInMonth; i++) {
+ objForm[pdmDays].options[i] = new Option(i+1);
}
- intMonth = parseInt(strMonth, 10);
- if (isNaN(intMonth)) {
- for (i=0; i<strMonthArray.length; i++) {
- if (strMonth == strMonthArray[i]) {
- intMonth = i+1;
- break;
- }
- }
- if (isNaN(intMonth)) {
- return false;
- }
- }
- if (intMonth > 12 || intMonth < 1) {
- return false;
- }
-
- intYear = parseInt(strYear, 10);
- if (isNaN(intYear)) {
- return false;
- }
- if (IsLeapYear(intYear) == true) {
- intDaysArray[1] = 29;
- }
-
- if (intday > intDaysArray[intMonth - 1]) {
- return false;
- }
-
- return true;
-}
-
-function IsLeapYear(intYear) {
- if (intYear % 100 == 0) {
- if (intYear % 400 == 0) {
- return true;
- }
+ if (selectedDay <= daysInMonth) {
+ objForm[pdmDays].options[selectedDay-1].selected = true;
} else {
- if ((intYear % 4) == 0) {
- return true;
- }
+ objForm[pdmDays].options[daysInMonth-1].selected = true;
}
-
- return false;
}
CVSspam 0.2.8
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click