function isEmail(strEmail)
{
if(strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
else
	return false;
}
function checkForm() {
	
    var name = document.mailForm.name.value;
	if(name.length == 0) {
		alert('name is requied.');
		document.mailForm.name.focus();
		return false;
	}
    
    var email = document.mailForm.email.value;
	if(email.length == 0) {
		alert('email is requied.');
		document.mailForm.email.focus();
		return false;
	}
    if(!isEmail(email))
	{
		alert('邮箱格式错误。');
	    document.mailForm.email.focus();
		return false;
	}
	/*
    var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
    chkFlag = pattern.test(email);
    if(chkFlag) {
    } else {
        alert('E-mail format error');
        document.mailForm.email.focus();
		return false;
    }
	*/
	var message = document.mailForm.message.value;
	if(message.length == 0) {
		alert('message is requied.');
		document.mailForm.message.focus();
		return false;
	}
	
	var idcode = document.mailForm.idcode.value;
	var result = jQuery('#result').text();
	if(idcode.length == 0) {
		alert('identifying code is requied.');
		document.mailForm.idcode.focus();
		return false;
	}else {
		if(!checkIdcode(idcode, result)) {
			alert('identifying code is wrong.');
			document.mailForm.idcode.focus();
			return false;
		}
	}

	return true;
}

//产生随机数
function boundrandom(bound1, bound2) {
	var bound1 = parseFloat(bound1);
	var bound2 = parseFloat(bound2);
	return Math.random() * (bound1 - bound2) + bound2;
}

//验证结果
function checkIdcode(idcode, result) {
	if(idcode == result) {
		return true;
	}else{
		return false;
	}
}

$(document).ready(function () {
	var a = Math.floor(boundrandom(1,100));
	var b = Math.floor(boundrandom(1,100));
	var result = a*b;
	$('#num1').text(a);
	$('#num2').text(b);
	$('#result').text(result);
});