//mhHover('Start ID name', 'Xth TD tag', 'Style name')
Program code
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.lengthreturn;
d[idx].className=cls;
}
//Drop-down menu, display hidden ID
// Usage method
//onChange="OptionNumber_change('Form name','The same part of the ID name (sequence number automatically takes the value)')"
//Note: The Value 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 {
document.getElementById(strOpt i).style.display = "";
}
for (j = 10; j > a; j--)
{
document.getElementById(strOpt j).style.display = "none";
}
}
//Read the database and display the hidden ID
// Usage
//
Program code
function ListNumber_change(ListObj,ListStr)
{
var a = ListObj;
for (i = 1; 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 the name of your iframe
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 checkboxes
//Usage:
//onclick=CheckAll(this.form,this.checked)
Program code
function CheckAll(form1, v) {
for (var i=0;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;
}
//Verification User name
Program code
function checkAccount(getO)
{
re= /^([a-z0-9]{4,12})$/gi
msg = "The username format is: 4-12 digits English lowercase (a-z) numbers (0-9)"
return regExpCheck(re,getO,msg)
}
// Verify password
Program code
function checkPassY(getO)
{
re= /^([A-Za-z0-9]{8,12})$/ gi
msg = "The login password format is: 8-12 digits English (A-Z, a-z) numbers (0-9)"
return regExpCheck(re,getO,msg)
}
//Verify real name
Program code
function checkNameN(getO)
{
re= /^[^',;$|@*]{2,10 }$/gi
msg = "Real name format error"
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 = gV.length-gV_c
gv_len = gV_c*2 gV_e
if (gv_len>20)
{
alert("Cannot be longer than 10 characters" )
return false;
}
else
return true
}
}
else
return false;
}
// Verify ID number
Program code
function checkIdCard(getO)
{
re= /^(([0-9]{15})|([0- 9a-z]{18}))$/gi;
msg = "ID card format error"
return regExpCheck(re,getO,msg)
}
//Verify electronic Email
Program code
function checkEmail(getO)
{
re= /^([.w-]){2,30}@([w-]) {3,30}(.([w]){2,4}){1,2}/gi
msg = "Email format error"
return regExpCheck(re,getO,msg)
}
//Verify zip code
Program code
function checkZipCode(getO)
{
re= /^([0-9]{6 })$/gi
msg = "Postal code format is: 6 digits (0-9)"
return regExpCheck(re,getO,msg)
}
//Verification Phone number
Program code
function checkPhone(getO)
{
re= /^([d]){2,5}-([d]){3,14}/gi
msg = "Telephone format error rnrn Please use "-" to separate the area code and phone number, for example: 029-82303721"
return regExpCheck(re ,getO,msg)
}
//Verify mobile phone number
Program code
function checkMobile(getO)
{
re= /^ (?[0-9]{0,3}13[0-9]{9})$/gi
msg = "Mobile phone format error"
return regExpCheck(re,getO,msg)
}
//Verification check code
Program code
function checkVcode(getO)
{
re= /^(d{4})$ /gi
msg = "Check code format error"
return regExpCheck(re,getO,msg)
}
//Verify number 1
function checkNumber(getO)
{
re= /^d $/gi
msg = "Format error, please enter a number from 0 to 9"
return regExpCheck(re,getO,msg)
}
//Verification Number 2
function checkNumberText(get0,msg0)
{
re = /^d $/gi
//msg = msg0
return regExpCheck(re,get0,msg0)
}