// javascript document //中部 $(document).ready(function(){ $("#button").click(function(){ validateform(); }); }); function postdata(){ $.ajax({ type: "post", url: "message.php", data: "mz="+$("#mz").val()+"&dh="+$("#dh").val()+"&nr="+$("#nr").val(), datatype: 'json', success: function(msg){ document.forms["myformb"]["mz"].value=""; document.forms["myformb"]["dh"].value=""; document.forms["myformb"]["nr"].value=""; alert(msg); } }); } $(document).ready(function(){ $("#kfbutton").click(function(){ validateform1(); }); }); function postdatakf(){ $.ajax({ type: "post", url: "message.php", data: "mz="+$("#mz1").val()+"&dh="+$("#dh1").val()+"&nr="+$("#nr1").val(), datatype: 'json', success: function(msg){ document.forms["myformb1"]["mz1"].value=""; document.forms["myformb1"]["dh1"].value=""; document.forms["myformb1"]["nr1"].value=""; alert(msg); } }); } function validateform() { var x=document.forms["myformb"]["mz"].value; var y=document.forms["myformb"]["dh"].value; var z=document.forms["myformb"]["nr"].value; if (x==null || x=="") { alert("请输入姓名"); return false; } else if (!(/^1[3|5|7|8][0-9]\d{4,8}$/.test(y))) { alert("请输入正确手机号码"); return false; } else if (z==null || z=="") { alert("请输入内容"); return false; } postdata(); } //弹出 function validateform1() { var x1=document.forms["myformb1"]["mz1"].value; var y1=document.forms["myformb1"]["dh1"].value; var z1=document.forms["myformb1"]["nr1"].value; if (x1==null || x1=="") { alert("请输入姓名"); return false; } else if (!(/^1[3|5|7|8][0-9]\d{4,8}$/.test(y1))) { alert("请输入正确手机号码"); return false; } else if (z1==null || z1=="") { alert("请输入内容"); return false; } postdatakf(); }