﻿/**
 * @FileName: register.js
 * @Author: Leo chxizi@gmail.com
 * @Date:  2009-10-6 09:22
 */

//去掉空格符
String.prototype.trim = function()
{
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}

//Email验证
function chekEmail(email) {  
 var pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i;  
 if(pattern.test(email)) {  
  return true;  
 }  
 else {  
  return false;  
 }  
}

//数字验证
function chekNumeric(num) {  
 var pattern = /^\d+(\.\d+)?$/;  
 if(pattern.test(num)) {  
  return true;  
 }  
 else {  
  return false;  
 }  
}

function checkLogin()
{
	var username = $("#username").val();
	var pwd = $("#passwords").val();
	if (username.trim() == "" || username.length < 6 )
	{
		alert("Please enter your Username.");
		$("#username").focus();
		return false;			
	}
	else if(chekEmail(username)==false)
	{
		alert("Invalid E-mail Address.");
		$("#username").focus();
		return false;	
	}	
	if (pwd.trim() == "" || pwd.length < 6)
	{
		alert("Please enter your Password.");
		$("#passwords").focus();
		return false;
	}
	$('#loginform').submit();
}