<!-- 判断填写内容是否超出预定长度，超出则返回true，并弹出提示框 -->
function outOfLength(sor, lth, altStr){
	if(sor.value.length > lth){
		alert(altStr);
		sor.select();
		return true;
	}
}

<!-- 判断字符串是否为空，空则返回true -->
function isNull(source){
	if(source == '')
		return true;
	else
		return false;
}

<!-- 判断字符串是否不空，不空返回true -->
function notNull(source){
	if(source != '')
		return true;
	else
		return false;
}

<!-- 判断字符串是否为空，为空则弹出提示框 -->
function isNullAlert(sor, altStr){
	if(isNull(sor.value)){
		alert(altStr);
		sor.focus();
		return true;
	}
}

<!-- 判断字符串是否为空，为空则弹出提示框，此方法不改变当前焦点 -->
function isNullAlertNoFocus(sor, altStr){
	if(isNull(sor.value)){
		alert(altStr);
		return true;
	}
}

<!-- 判断填写内容是否为数字，不是数字则弹出提示框 -->
function notNumber(sor, altStr){
	if(isNaN(sor.value)){
		alert(altStr);
		sor.select();
		return true;
	}
}

<!-- 判断单选框是否被选中 -->
function isCheckedForRadio(cheRadio){
	for(var i=0; i<cheRadio.length; i++){
		if(cheRadio[i].checked)
			return true;
	}
}

<!-- 如果单选框未被选中则弹出提示框 -->
function noCheckedAlert(cheRadio, altStr){
	if(!isCheckedForRadio(cheRadio)){
		alert(altStr);
		return true;
	}
}

<!-- 判断选择框是否被选中 -->
function isSelected(selOption){
	for(var i=0; i<selOption.options.length; i++){
		if(selOption.options[i].selected)
			return true;
	}
}

<!-- 如果选择框未被选中则弹出提示框 -->
function noSelectedAlert(selOptions, altStr){
	if(!isSelected(selOptions))
		alert(altStr);
}

<!-- 将已选中的src中的内容添加到aim中 -->
function test(src, aim){
	for(var i=0; i<src.options.length; i++){
		if(src.options[i].selected && !haveValueInSelect(src.options[i].selected, aim)){
			var aimOp = document.createElement('OPTION');
			aim.appendChild(aimOp);
			aimOp.value = src.options[i].value;
			aimOp.text = src.options[i].text;
			src.options[i].value = '';
		}
	}
	delNullOptions(src);
}

<!-- 判断此选择框中是否有传进的str值 -->
function haveValueInSelect(str, sel){
	var have = false;
	for(var i=0; i<sel.options.length; i++){
		if(sel.options[i].value == str){
			have = true;
			break;
		}
	}
	return have;
}

<!-- 删除内容为空的option -->
function delNullOptions(sel){
	for(var i=sel.options.length-1; i>=0; i--){
		if(sel.options[i].value == '')
			sel.options[i] = null;
	}
}
