![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 thencrash ![]()
![]() |
var xmlhttp; function createXMLHttpRequest(){ if(window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); else if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); } function startRequest(){ createXMLHttpRequest(); var acc = document.formAdd.acc.value; var surl = "chkacc.php?timestamp=" + new Date().getTime(); var poststr = "acc=" + acc; xmlhttp.open("POST",surl); xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200) alert(xmlhttp.responseText); } xmlhttp.send(poststr); } </script> <script type="text/javascript"> function chkreg(month) { var x = month.selectedIndex; var y = year.selectedIndex; var mon = month.options[x].text; var yoy = year.options[y].text; var hh; var str; var chk; var errcount=0; hh=yoy+"/"+mon+ "/" +document.formAdd.inputday.value; document.getElementById("date").value= hh; str=document.formAdd.acc.value; chk=/^[a-zA-z0-9]+/; if(str.length<6 || str.length >12 || !str.match(chk)){ alert('帳號格式錯誤'); document.formAdd.acc.focus(); errcount++; return false; } . . . . . str=document.formAdd.email.value; chk=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/; if(str.length <7 || !str.match(chk)){ alert('email格式錯誤'); document.formAdd.email.focus(); errcount++; return false; } if(errorcount==0) return true; } </script> <body> <form action="" method="post" name="formAdd" id="formAdd" onSubmit="return chkreg(month);"> <p> <label for="acc">帳號:</label> <input type="text" name="acc" id="acc" onblur="startRequest()"/> <br/> <label for="pw">密碼:</label> <input type="text" name="pw" id="pw" /> . . . . . </form> </body> 原本只跑chkreg這個function是沒問題的 但因為想要加入檢查帳號這個功能就另外用了startRrquest這個function 但一加入這功能之後反而變成startRequest()能用,return chkreg(month)卻不會執行了 新手上路還請各位大大不吝指教QQ |