JS常用工具方法

function checkEmail(){
		var emailResult = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test($("#primaryEmail").val());
		if(!emailResult){
			alertMsg.error("邮箱格式错误");
		}
		return emailResult;
	}

	function checkBirthDay(){
		var birthday = $("#birthday").val();
		var checkFormat = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/.test(birthday);
		if (!checkFormat) {
			alertMsg.error("请输入正确的生日");
			return false;
		}
		birthday = birthday.replace(/-/g,"/");
		var birthDate = new Date(birthday);
		var now = new Date();
		if (null == birthDate) {
			alertMsg.error("请输入正确的生日");
			return false;
		}
		if (birthDate > now) {
			alertMsg.error("生日不能大于今天");
			return false;
		}
		return true;
	}

猜你喜欢

转载自harveyzeng.iteye.com/blog/2206061