mindtechuser
asked on
PHP site register button not working
I have php web site that I've trying to fix and I have most of issues fixed but two last issue I still have.
They are Registration button and Service Request button. I can't find anything wrong with script but it just does do anything when I click the button.
Following are the actual Java script and html button function code, please take a look at it and see if you can find any issue with it.
Any help would be very appreciated.
Thank you,
They are Registration button and Service Request button. I can't find anything wrong with script but it just does do anything when I click the button.
Following are the actual Java script and html button function code, please take a look at it and see if you can find any issue with it.
Any help would be very appreciated.
Thank you,
======================
script in request.php
======================
<script type="text/JavaScript">
<!--
function checkEmail(email){
var IsValid = true;
var AtSymbolAt = email.indexOf('@');
var LastDotAt = email.lastIndexOf('.');
var SpaceAt = email.indexOf(' ');
var Length = email.length;
if (AtSymbolAt < 1 ) {IsValid = false}
if (LastDotAt < AtSymbolAt) {IsValid = false}
if (Length - LastDotAt <= 2) {IsValid = false}
if (SpaceAt != -1) {IsValid = false}
return IsValid;
}
function submitIt(){
if (!checkEmail(frmMail.email_from.value)){ //check email field
alert("The <Email> is a required field!\nPlease, enter a valid email.");
document.frmMail.email_from.focus();
document.frmMail.email_from.select();
return false;
}
if (frmMail.uname.value == ""){ //check uname field
alert("The <Name> is a required field!\nPlease, enter your name.");
document.frmMail.uname.focus();
document.frmMail.uname.select();
return false;
}
if (frmMail.address.value == ""){ //check address field
alert("The <Address> is a required field!\nPlease, enter your address.");
document.frmMail.address.focus();
document.frmMail.address.select();
return false;
}
if (frmMail.city.value == ""){ //check city field
alert("The <City> is a required field!\nPlease, enter your city.");
document.frmMail.city.focus();
document.frmMail.city.select();
return false;
}
if (frmMail.state.value == ""){ //check state field
alert("The <State> is a required field!\nPlease, enter your state.");
document.frmMail.state.focus();
document.frmMail.state.select();
return false;
}
if (frmMail.zip.value == ""){ //check zip field
alert("The <Zip> is a required field!\nPlease, enter your zip code.");
document.frmMail.zip.focus();
document.frmMail.zip.select();
return false;
}
if (frmMail.item1.value == ""){ //check item1 field
alert("The <Item #1> is a required field!\nPlease, enter the choosen item.");
document.frmMail.item1.focus();
document.frmMail.item1.select();
return false;
}
document.frmMail.submit();
return true ;
}
-->
</script>
<INPUT name="but_submit" type=button onClick="return submitIt();" value="Submit">
===========================
script in registration.php
===========================
<script type="text/JavaScript">
<!--
function checkEmail(email){
var IsValid = true;
var AtSymbolAt = email.indexOf('@');
var LastDotAt = email.lastIndexOf('.');
var SpaceAt = email.indexOf(' ');
var Length = email.length;
if (AtSymbolAt < 1 ) {IsValid = false}
if (LastDotAt < AtSymbolAt) {IsValid = false}
if (Length - LastDotAt <= 2) {IsValid = false}
if (SpaceAt != -1) {IsValid = false}
return IsValid;
}
function submitIt(){
if (frmReg.name.value == ""){ //check name field
alert("The <Name> is a required field!\nPlease, enter your name.");
document.frmReg.name.focus();
document.frmReg.name.select();
return false;
}
if (!checkEmail(frmReg.email.value)){ //check email field
alert("The <Email> is a required field!\nPlease, enter a valid email.");
document.frmReg.email.focus();
document.frmReg.email.select();
return false;
}
if (frmReg.password.value == ""){ //check pswd field
alert("The <Password> is a required field!\nPlease, enter a password.");
document.frmReg.password.focus();
document.frmReg.password.select();
return false;
}
if (frmReg.password2.value == ""){ //check pswd2 field
alert("The <Confirm password> is a required field!\nPlease, enter a password.");
document.frmReg.password2.focus();
document.frmReg.password2.select();
return false;
}
if (frmReg.password.value != frmReg.password2.value){ //check pswd <> pswd2 fields
alert("The <Confirm password> field must be equal with a <password> field!\nPlease, reenter.");
document.frmReg.password2.focus();
document.frmReg.password2.select();
return false;
}
document.frmReg.submit();
return true ;
}
-->
</script>
<input type="button" value="Register" onClick="submitIt()">
You seem to be missing <form> and </form> tags?
In the onClick part, instead of submitIt() you may wish to try submitIt without the brackets. Used to happen to me all the time :)
ASKER
I do have <form></form> I just did not copy it that.
I've tried submiIt with out () but it is still the same
I've tried submiIt with out () but it is still the same
Suggestion - put an alert at the top of your submitIt() function and at the bottom (right before document.form.submit()) to see if it's executiing the function at all. Are you getting any javascript errors in the browser (I recommend Firefox with Firebug for debugging Javascript) when you click on the button?
ASKER
I just find out that this code is working just fine in IE but not working in Firefox. Anyone knows why?
Any input is appreciated.
Any input is appreciated.
Can you post the forms too?
Try adding these two lines to the first line of your functions (see code snippet)
var frmMail = document.frmMail;
var frmReg = document.frmReg;
var frmMail = document.frmMail;
var frmReg = document.frmReg;
function submitIt(){
var frmMail = document.frmMail;
if (!checkEmail(frmMail.email_from.value)){ //check email field
alert("The <Email> is a required field!\nPlease, enter a valid email.");
document.frmMail.email_from.focus();
document.frmMail.email_from.select();
return false;
}
function submitIt(){
var frmReg = document.frmReg;
if (frmReg.name.value == ""){ //check name field
alert("The <Name> is a required field!\nPlease, enter your name.");
document.frmReg.name.focus();
document.frmReg.name.select();
return false;
}
ASKER
I've copied and pasted the line above but nothing worked on both IE and Firefox.
Below is the actual form for both Register.php & Request.php.
I really appreciate you for look into this.
Below is the actual form for both Register.php & Request.php.
I really appreciate you for look into this.
=======================
form for register.php
=======================
<form action="register.php" method="POST" name="frmReg">
<tr>
<td colspan="3"><font color="#ff0000">* required fields</font></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td align="left"><font color="#ff0000">* </font>Name:</td>
<td width="10"> </td>
<td align="left"><input name="name" type="text" value="" size="20"></td>
</tr>
<tr>
<td align="left"><font color="#ff0000">* </font>Email:</td>
<td width="10"> </td>
<td align="left"><input name="email" type="text" value="" size="20"></td>
</tr>
<tr>
<td align="left"><font color="#ff0000">* </font>Password:</td>
<td width="10"> </td>
<td align="left"><input name="password" type="password" value="" maxlength="15" size="20"></td>
</tr>
<tr>
<td align="left"><font color="#ff0000">* </font>Confirm password:</td>
<td width="10"> </td>
<td align="left"><input name="password2" type="password" value="" maxlength="15" size="20"></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td align="left">Company:</td>
<td width="10"> </td>
<td align="left"><input name="company" value="" size="20"></td>
</tr>
<tr>
<td align="left">Address:</td>
<td width="10"> </td>
<td align="left"><input name="address" value="" size="20"></td>
</tr>
<tr>
<td align="left">City:</td>
<td width="10"> </td>
<td align="left"><input name="city" value="" size="20"></td>
</tr>
<tr>
<td align="left">State:</td>
<td width="10"> </td>
<td align="left"><input name="state" value="" size="20"></td>
</tr>
<tr>
<td align="left">ZIP:</td>
<td width="10"> </td>
<td align="left"><input name="zip" value="" size="20"> </td>
</tr>
<tr>
<td align="left">Phone:</td>
<td width="10"> </td>
<td align="left"><input name="phone" value="" size="20"></td>
</tr>
<tr>
<td align="left">Fax:</td>
<td width="10"> </td>
<td align="left"><input name="fax" value="" size="20"></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td><b><a href="index.php">Registered user login</a></b></td><td></td>
<td align="right"><input type="button" value="Register" onClick="return submitIt();"></td>
</tr>
</form>
=======================
form for request.php
=======================
<FORM name="frmMail" action="request.php" method=post>
<INPUT type=hidden value="<?php echo $email_to;?>" name='email_to'>
<TBODY>
<TR><TD style="FONT-SIZE: 9pt; COLOR: #008800" align=middle colSpan=2><B>Please allow 1-2 day response for this request</B></TD></TR>
<TR><TD align=left colSpan=2><HR><font style="COLOR: #880000">* Required Field</font></TD></TR>
<TR>
<TD align=left class=item width="30%">Name<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='uname'></TD>
</TR>
<TR>
<TD align=left class=item>Email<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='email_from'></TD></TR>
<TR><TD colSpan=2> </TD></TR>
<TR>
<TD align=left class=item>Company Name:</TD>
<TD><INPUT name='company'></TD>
</TR>
<TR>
<TD align=left class=item>Address<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='address'></TD>
</TR>
<TR>
<TD align=left class=item>City<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='city'></TD>
</TR>
<TR>
<TD align=left class=item>State<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='state'></TD>
</TR>
<TR>
<TD align=left class=item>Zip Code<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='zip'></TD>
</TR>
<TR>
<TD align=left class=item>Country:</TD>
<TD><INPUT name='country'></TD>
</TR>
<TR>
<TD align=left class=item>Phone#<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='phone'></TD>
</TR>
<TR>
<TD align=left class=item>Fax#:</TD>
<TD><INPUT name='fax'></TD>
</TR>
<TR><TD colSpan=2> </TD></TR>
<TR><TD class=item align=left colSpan=2><B>Please provide our part# or a Competitor's part# along with quantity</B></TD></TR>
<TR>
<TD align=left class=item>Part #1<B style="COLOR: #880000">*</B>:</TD>
<TD><INPUT name='item1'></TD>
</TR>
<TR>
<TD align=left class=item>Part #2:</TD>
<TD><INPUT name='item2'></TD>
</TR>
<TR>
<TD align=left class=item>Part #3:</TD>
<TD><INPUT name='item3'></TD>
</TR>
<TR>
<TD align=left class=item>Part #4:</TD>
<TD><INPUT name='item4'></TD>
</TR>
<TR>
<TD align=left class=item>Part #5:</TD>
<TD><INPUT name='item5'></TD>
</TR>
<TR>
<TD colspan=2 align="left" class=item><INPUT type=checkbox value=Catalog name='request1'><B>Request 2007 Table of Dimensions</B></TD></TR>
<TR>
<TD colspan=2 align="left" class=item><INPUT type=checkbox value=eCatalog name='request2'><B>Request 2007 Net Price List</B></TD>
</TR>
<TR><TD colSpan=2> </TD></TR>
<TR><TD class=item align=middle colSpan=2>Additional Comments?</TD></TR>
<TR><TD colSpan=2><TEXTAREA style="width: 400px;" name='comments' rows=6></TEXTAREA></TD></TR>
<TR><TD colSpan=2><HR></TD></TR>
<TR>
<TD align=left><INPUT type=reset value="Reset"></TD>
<TD align=right><INPUT name="but_submit" type=button value="Submit" onClick="return submitIt();"></TD>
</TR>
</FORM>
The forms worked for me just fine when I copied and pasted them into a sample page (in both IE and Firefox). Are you getting a Javascript error in Firefox? It should tell you what line the error is on - that might help narrow it down. Are there other scripts or forms also on the page that might be interfering?
ASKER
As far as I know there is no interfering and there is no Java Script error. It just don't do anything when I click on Submit button.
Man, this thing is driving me crazy.
Thanks for your help
Man, this thing is driving me crazy.
Thanks for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This script worked / I thank you so much for help from all of you.
ASKER
Thank you all for you help and I really appreciate it.