// Mhhover ('start ID name', 'nth TD label', 'style name ')
ProgramCode
Function mhhover (TBL, idx, CLS ){
VaR T, D;
If (document. getelementbyid) t = Document. getelementbyid (TBL );
Else t = Document. All (TBL );
If (t = NULL) return;
If (T. getelementsbytagname) d = T. getelementsbytagname ("TD ");
Else d = T. All. Tags ("TD ");
If (D = NULL) return;
If (D. Length <= idx)
Return;
D [idx]. classname = CLS;
}
// Drop-down menu to show hidden IDS
// Usage
// Onchange = "optionnumber_change ('form name', 'Id with the same name (sequence number automatically taken )')"
// Note: the value of the form must be a number.
Program code
Function optionnumber_change (selobj, stropt)
{
VaR A = (selobj. Options [selobj. selectedindex]. value );
For (I = 1; I <= A; I ++)
{
Document. getelementbyid (stropt + I). style. Display = "";
}
For (j = 10; j> A; j --)
{
Document. getelementbyid (stropt + J). style. Display = "NONE ";
}
}
// Read the database and show the hidden ID
// Usage
//
Program code
Function listnumber_change (listobj, liststr)
{
VaR A = listobj;
For (I = 1; I <= A; I ++)
{
Document. getelementbyid (liststr + I). style. Display = "";
}
For (j = 10; j> A; j --)
{
Document. getelementbyid (liststr + J). style. Display = "NONE ";
}
}
// IFRAME adaptive height
// Usage:
// Onload = "resizeframe ('iframe ID name ')"
Program code
Function resizeframe (frameid) {// frameid is your ifream name
Try {
VaR obody = eval (frameid + ". Document. Body ");
VaR oframe = Document. All (frameid );
Oframe. style. Height = obody. scrollheight + (obody. offsetheight-obody. clientheight );
}
Catch (e ){
Window. Status = 'error: '+ E. Number +'; '+ E. description;
}
}
// Select all check boxes
// Usage:
// Onclick = checkall (this. form, this. Checked)
Program code
Function checkall (form1, v ){
For (VAR I = 0; I <form1.elements. length; I ++ ){
VaR E = form1.elements [I];
If (E. type = 'checkbox') E. Checked = V;
}
}
// Verify the correctness of the form string expression
Program code
Function regexpcheck (Re, Geto, MSG)
{
If (Re. Test (Geto. Value) = false)
{
If (Geto. msg)
{
MSG = Geto. MSG + msg
}
Alert (MSG)
Geto. Focus ();
Return false;
}
Return true;
}
// Verify the user name
Program code
Function checkaccount (Geto)
{
Re =/^ ([a-z0-9] {}) $/Gi
MSG = "username format: 4-12 digits in lowercase (a-z) (0-9 )"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the password
Program code
Function checkpassy (Geto)
{
Re =/^ ([A-Za-z0-9] {8, 12}) $/Gi
MSG = "Login Password format: 8-12 English (A-Z, A-z) number (0-9 )"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the real name
Program code
Function checknamen (Geto)
{
Re =/^ [^ \ '\, \ ;\\ |\@\*] {} $/Gi
MSG = "Incorrect real name format"
Xx = regexpcheck (Re, Geto, MSG)
If (xx = true)
{
Re =/[^-}]/Gi
GV = Geto. Value
If (GV. Match (re) = NULL)
Return true
Else
{
Gv_c = (GV. Match (re). Length
Gv_e = V. length-gV_c
Gv_len = gv_c * 2 + gv_e
If (gv_len> 20)
{
Alert ("cannot exceed 10 characters ")
Return false;
}
Else
Return true
}
}
Else
Return false;
}
// Verify the ID card number
Program code
Function checkidcard (Geto)
{
Re =/^ ([0-9] {15}) | ([0-9a-z] {18}) $/GI;
MSG = "Incorrect ID card format"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the email
Program code
Function checkemail (Geto)
{
Re =/^ ([\. \ W-]) {2, 30} @ ([\ W-]) {3, 30 }(\. ([\ W]) {2, 4}) {1, 2}/Gi
MSG = "Incorrect email format"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the zip code
Program code
Function checkzipcode (Geto)
{
Re =/^ ([0-9] {6}) $/Gi
MSG = "zip code format: 6 digits (0-9 )"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the phone number
Program code
Function checkphone (Geto)
{
Re =/^ ([\ D]) {2, 5}-([\ D]) {3, 14}/Gi
MSG = "phone format error \ r \ n region number and phone number should be separated by"-", for example: 029-82303721"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the mobile phone number
Program code
Function checkmobile (Geto)
{
Re =/^ (\ +? [0-9] {0, 3} 13 [0-9] {9}) $/Gi
MSG = "Incorrect mobile phone format"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the verification code
Program code
Function checkvcode (Geto)
{
Re =/^ (\ D {4}) $/Gi
MSG = "Incorrect verification code format"
Return regexpcheck (Re, Geto, MSG)
}
// Verify the number 1
Function checknumber (Geto)
{
Re =/^ \ D + $/Gi
MSG = "format error. Enter 0 ~ 9 digit"
Return regexpcheck (Re, Geto, MSG)
}
// Verify number 2
Function checknumbertext (get0, msg0)
{
Re =/^ \ D + $/Gi
// MSG = msg0
Return regexpcheck (Re, get0, msg0)
}