// Name: extendCheck ()
// Role: Check the type of upload file
// Language: JavaScript
// Author: Chenzhen Quan
/ / Date: 2004-10-7
// Parameter: None // Return Value: True / False
// Upfile - File Component ID
// Call Method: Suppose cmdsave is the ID of the upload button, then add the following code:
//cmdsave.attributes ["onclick"]="javascript:return extendcheck () ";
Function extendCheck ()
{
IF (window.form1.upfile.value == "")
{
Alert ("Please select the photo you want to upload!");
Return False;
}
Else
{
Var pathname = window.form1.upfile.value;
VAR num = pathname.lastindexof (".");
Var ExName = pathname.substr (Num 1, Pathname.length - Num);
Switch (ExName.tolowcase ())
{
// Change the allowed file type here, must be lowercase
Case "JPG":
Case "GIF":
Case "BMP":
Case "JPGE":
Return True;
Break;
DEFAULT:
Alert ("The file type is incorrect");
Return False;
Break;
}
}
}
//
// Name: getDaynum ()
// Role: Return the number of days of the specified month
// Language: VBScript
/ / Date: 2004-10-8
// Parameters: D - Specified specific date, such as 2004-10-8
// Return Value: Enter the date of the correct format, return to the days of the day, otherwise returns 0
// Use: Num = getDaynum ("2004-10-8")
Function GetDaynum (D)
IF not isdate (d) THEN
GetdayNum = 0
Else
Y = year (d)
M = Month (d)
m = m 1
D = DateAdd ("D", - 1, Y & "-" & M & "-" & "01")
GetdayNum = day (d)
END IF
END FUNCTION
//// javaScript version //
Function getDaynum (date)
{
VAR RE = / ^ (/ d {4}) (0 [1-9] | 1 [0-2]) (0 [1-9] | [1-2] / D | 3 [0-1]) $ /
IF (Re.test (Date))
{
Var hasDate = new date (date);
Var year = thisdate.getfullyear ();
VAR MONTH = thisdate.getMonth () 1;
Var daynum = new date (year, month, 0) .getdate ();
Return (NUM);
}
Else
{
Return 0;
}
}