<button class="a1 active" type="submit" id="tj">提交</button> <script> $(function(){ $('#tj').click(function(){ //alert(1) if($('#message').val()==''){alert('请输入留言内容!');return false;} if($('#name').val()==''){alert('请输入您的姓名!'); $("#name").focus(); return false;} if ($("#tel").val() == "") { alert("请输入你的手机!"); $("#tel").focus(); return false; } if (!$("#tel").val().match(/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/)) { alert("手机号码格式不正确!"); $("#tel").focus(); return false;} if ($("#email").val() == "") { alert("请输入电子邮箱!"); return false; } if (!$("#email").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) { alert("电子邮箱格式不正确"); $("#email").focus(); return false; } }) }) </script>
标签: