Hi try to submit user data from client side to server side by changing action attribute after validation has completed (It is something I did in the past and suddenly it is not working). My html form(post)
<!-- Submit data to server-side -->
<form id="register" method="post">
<table class="tableReg" border="0">
<tr class="rowReg">
<td>User name:</td>
<td><input onfocus="resetColor('userID')" type="text" id="userID" name="user"></td>
<td id=note1></td>
</tr>
<tr class="rowReg">
<td>Password:</td>
<td>
<input onfocus="resetColor('passwordID1')" type="password" id="passwordID1" name="password1">
</td>
<td id=note2></td>
</tr>
<tr class="rowReg">
<td>Repeat Password:</td>
<td>
<input onfocus="resetColor('passwordID2')" type="password" id="passwordID2" name="password2">
</td>
<td id=note3></td>
</tr>
<tr class="rowReg">
<td>Email:</td>
<td><input onfocus="resetColor('emailID1')" type="email" id="emailID1" name="email1"></td>
<td id=note4></td>
</tr>
<tr class="rowReg">
<td>Repeat Email:</td>
<td><input onfocus="resetColor('emailID2')" type="email" id="emailID2" name="email2"></td>
<td id=note5></td>
</tr>
</table>
<input type="button" onclick="checkInput()" value="Submit">
</form>
If you see after I press the sumbit button the information is checked and if passed validation is being sent to server side, I used javaScript:
function checkInput(){
var regexUser = /^(?=.{1,20}$)[a-zA-Z0-9]+$/;//all letters ad number and size between 1-20
var regextPwd = /^(?=.{8,8}$)(?=.*[a-zA-Z])(?=.*\d)(?=.*[!#$%&? "]).*$/; //Password must contain 8 characters and
// at least one number, one letter and one
// unique character such as !#$%&?
//Email regex
var regexMail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var errorArr = new Array(0,0,0,0,0);
document.getElementById("register").action = "databasebuilder.php";}
Now after I validate input it suppose to send to databasebuilder.php which is in the same directory on my local host but it doesn't!
I already tested it without and it should be reachable why document.getElementById("register").action is not working.
Why dont you submit the form by yourself. Like this...
document.getElementById("register").action = "databasebuilder.php";
document.getElementById("register").submit();
Try this,
Add this in your js function
document.getElementById("register").action= "databasebuilder.php";
reutrn true;
Also change the type
from button
to submit
like
<input type="submit" onclick="return checkInput()" value="Submit">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.