<script type="text/javascript">
$(function () {
$("#birthday").datepick({ dateFormat: 'yyyy-mm-dd',yearRange: '1900:2020' });
$('#sendBtn').click(function(){
if($.trim($('#testname').val()) == ''||$.trim($('#testname').val()) == '请输入您的姓名'){
alert("请填写姓名!");
$('#testname').focus();
return;
}
if (($.trim($('#testname').val()).length>30)||($.trim($('#testname').val()).length<2)) {
alert("请输入正确的姓名!");
$('#testname').focus();
return;
}
if($.trim($('#birthday').val()) == ''||$.trim($('#birthday').val()) == '请输入您的生日'){
alert("请填写生日!");
$('#birthday').focus();
return;
}
if (/^(\d{4})([-])(\d{2})([-])(\d{2})/.test($.trim($('#birthday').val())) == false) {
alert("日期格式不正确!\n正确格式为:1988-04-28");
$('#birthday').focus();
return;
}
if($.trim($('#phone').val()) == ''||$.trim($('#phone').val()) == '请输入您的手机号码'){
alert("请填写手机!");
$('#phone').focus();
return;
}
if (/0{0,1}(13[0-9]|15[3-9]|15[0-2]|18[0-9])[0-9]{8}$/.test($.trim($('#phone').val())) == false) {
alert("请输入正确11位有效的手机号码!");
$('#phone').focus();
return;
}
if($.trim($('#email').val()) == ''||$.trim($('#email').val()) == '请输入您的邮箱地址'){
alert("请填写邮箱!");
$('#email').focus();
return;
}
if (/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test($.trim($('#email').val())) == false) {
alert("邮箱格式不正确!");
$('#email').focus();
return;
}
if (($.trim($('#email').val()).length>31)||($.trim($('#email').val()).length<7)) {
alert("请输入正确的邮箱!");
$('#email').focus();
return;
}
document.getElementById('sendBtn').style.display = 'none';
document.getElementById('msgspan').style.display = 'block';
$.post("/front/website/testuser/getReport",
{testname:$("#testname").val(),
birthday:$("#birthday").val(),
phone:$("#phone").val(),
email:$("#email").val()
},
function(date){
alert("报告已发送,请注意查收!");
document.getElementById('msgspan').style.display = 'none';
document.getElementById('sendBtn').style.display = 'block';
});
});
});
</script>
$(function () {
$("#birthday").datepick({ dateFormat: 'yyyy-mm-dd',yearRange: '1900:2020' });
$('#sendBtn').click(function(){
if($.trim($('#testname').val()) == ''||$.trim($('#testname').val()) == '请输入您的姓名'){
alert("请填写姓名!");
$('#testname').focus();
return;
}
if (($.trim($('#testname').val()).length>30)||($.trim($('#testname').val()).length<2)) {
alert("请输入正确的姓名!");
$('#testname').focus();
return;
}
if($.trim($('#birthday').val()) == ''||$.trim($('#birthday').val()) == '请输入您的生日'){
alert("请填写生日!");
$('#birthday').focus();
return;
}
if (/^(\d{4})([-])(\d{2})([-])(\d{2})/.test($.trim($('#birthday').val())) == false) {
alert("日期格式不正确!\n正确格式为:1988-04-28");
$('#birthday').focus();
return;
}
if($.trim($('#phone').val()) == ''||$.trim($('#phone').val()) == '请输入您的手机号码'){
alert("请填写手机!");
$('#phone').focus();
return;
}
if (/0{0,1}(13[0-9]|15[3-9]|15[0-2]|18[0-9])[0-9]{8}$/.test($.trim($('#phone').val())) == false) {
alert("请输入正确11位有效的手机号码!");
$('#phone').focus();
return;
}
if($.trim($('#email').val()) == ''||$.trim($('#email').val()) == '请输入您的邮箱地址'){
alert("请填写邮箱!");
$('#email').focus();
return;
}
if (/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test($.trim($('#email').val())) == false) {
alert("邮箱格式不正确!");
$('#email').focus();
return;
}
if (($.trim($('#email').val()).length>31)||($.trim($('#email').val()).length<7)) {
alert("请输入正确的邮箱!");
$('#email').focus();
return;
}
document.getElementById('sendBtn').style.display = 'none';
document.getElementById('msgspan').style.display = 'block';
$.post("/front/website/testuser/getReport",
{testname:$("#testname").val(),
birthday:$("#birthday").val(),
phone:$("#phone").val(),
email:$("#email").val()
},
function(date){
alert("报告已发送,请注意查收!");
document.getElementById('msgspan').style.display = 'none';
document.getElementById('sendBtn').style.display = 'block';
});
});
});
</script>