var msg='';
function check(frm){
	msg='';
	isValidate(frm.username.value,'account','username',6,10) ;
	isValidate(frm.password.value,'password','password',6,10) ;
	isValidate(frm.email.value,'email','email',-1,-1);
	if( msg=='' ){
		return true;
	}else{
		alert(msg);
	}
	return false;
}
function inputcheck(frm){
	msg='';
	isValidate(frm.value,'string',frm.name,1,60) ;
	if( msg=='' ){
		return true;
	}else{
		alert(msg);
	}
	frm.focus();
	return false;
}
function isValidate(vstr,vtype,vtitle,vmin,vmax){
	if(vtype=='account' && vtitle=='username' && vstr=='admin'){
		return true;
	}
	if(vtype=='password' && vtitle=='password' && vstr==''){
		return true;
	}
	if(vtype=='account' || vtype=='password'){
		if(!(/^[a-zA-Z0-9_]+$/).test(vstr)){
			msg += 'Only number , character or _ is alowed for ' + vtitle + ' !\n';
		}
		if(vmin > -1){
			if( vstr.length < vmin){
				msg += 'The min length of '+ vtitle + ' is '+ vmin + ' !\n';
			}
		}
		if(vmax > -1){
			if(vstr.length > vmax){
				msg += 'The max length of '+ vtitle +' is '+ vmax +' !\n';
			}
		}
	}else if(vtype=='email'){
		if(!(/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/).test(vstr)){
			msg += 'The email you input is a bad email!\n';		
		}
	}else if(vtype=='number'){
		if(!(/^[0-9]+$/).test(field.value)){
			msg += 'The ' + vtitle + ' must be a number!';		
		}
		if(vmin > -1){
			if(vstr < vmin){
				msg += 'The min value of '+ vtitle + ' is '+ vmin + ' !\n';
			}
		}
		if(vmax > -1){
			if(vstr > vmax){
				msg += 'The max value of ' + vtitle + ' is '+ vmax +' !\n';
			}
		}
	}else if(vtype=='string'){		
		if(vmin > -1){
			if( vstr.length < vmin){
				msg += 'The min length of '+ vtitle + ' is '+ vmin + ' !\n';
			}
		}
		if(vmax > -1){
			if(vstr.length > vmax){
				msg += 'The max length of '+ vtitle +' is '+ vmax +' !\n';
			}
		}
	}else{
	}
	return true;
}

