我已經完成了php.I的註冊頁面使用JavaScript執行驗證我已經完成了驗證,但我不知道提交到下一頁的細節的語法。這是我的代碼我是一個非常新的PHP初學者,所以需要你的幫助。 感謝您在advance..sorry我的英文不好如何通過javascript驗證後提交表格
register.php
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var a = document.getElementById('n1').value;
if(a==""){
alert("please enter your name");
return false;
}
var b = document.getElementById('u1').value;
if(b==""){
alert("please enter the username");
return false;
}
var p3 = document.getElementById('p1').value;
if(p3==""){
alert("please enter the password");
return false;
}
var p4 = document.getElementById('p2').value;
if(p4==""){
alert("please enter the confirmation password");
return false;
}
//if(p3.value!=p4.value){
//alert("hh");
//alert("Passwords do no match");
//return false;
//}else{
//return true;
//}
var c = document.getElementById('a1').value;
if(c==""){
alert("please enter your address");
return false;
}
var d = document.getElementById('ph').value;
if(d==""){
alert("please enter your phone no:");
return false;
}
(48) document.registrationform.submit;
}
</script>
</head>
<body>
<form action ="#" name="registrationform" id=="formid" class="formclass" action="registerbackend.php" method ="post" >
name :<input type="text" id="n1" name="name"><br><br>
username:<input type="text" id="u1" name="username"><br><br>
password:<input type="password" id="p1" name="password"><br><br>
confirm password:<input type="password" id="p2" name="password2"><br><br>
Address :<textarea name="address" id= "a1"rows="4" cols="40"></textarea><br><br>
phone :<input id="ph" type="numbers" name="phone"><br><br>
(62) <input type="button" name="register" onclick="validateForm()" value="Register">
<a href="login.php"><input id="button" type="button" value="cancel"> </a>
</form>
</body>
</html>
的[使用AJAX提交表單]可能的複製(http://stackoverflow.com/questions/13611614/submit-the-form -using-ajax) –