PDA

View Full Version : Email form help



mukhtar88
07-12-2007, 09:09 AM
Hi,

I have a download page to which I re-direct people via a form page which has the following fields

Name, Country, Email address and a hidden field which sends this form to my email address via my host bravenet and on click "submit" re-directs the person to download page.

here is the address
http://fengshuihope.bravehost.com/downloadentry.htm
(View page source)

I have added a script in the head section which prompt the person not to leave the fields blank. Some people do not enter a valid email address instead write any name in the email text box. The script in the head section only checks whether the fields are full or blank but does not check whether it is valid or not. How do I avoid this problem.


Script in the head section.
<script>

/*
Check required form elements script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}
else
return true
}

</script>

Script in the body section
<form method="post" onsubmit="return checkrequired(this)" enctype="multipart/form-data" action="http://pub32.bravenet.com/emailfwd/senddata.php">
<b><font color="#006600"><input name="usernum" value="2704960386" style="border: 0px solid rgb(0, 0, 0); width: 0px; height: 0px;" type="hidden">
<input name="cpv" value="2" style="border: 0px solid rgb(0, 0, 0); width: 0px; height: 0px;" type="hidden">
<!-- DO NOT CHANGE OR REMOVE THE 3 TAGS ABOVE THIS COMMENT-->
</font></b><div align="left"><label for="thankyou" style="display: none;"><b><font color="#006600">hidden field</font></b></label><b><font color="#006600"><input value="http://fengshuihope.bravehost.com/download1.htm" id="thankyou" name="thankyou" style="border: 0px solid rgb(0, 0, 0); width: 0px; height: 0px;" type="hidden"></font></b><div style="clear: left; height: 20px; display: none;"><b><font color="#006600"> </font></b></div>
<table border="0" cellpadding="0" cellspacing="3">
<tbody><tr>
<td><strong>Name: </strong></td>
<td><input name="requiredname" size="35" type="text"> <font color="#ff0080">*</font></td>
</tr>
<tr>
<td><strong>Country:</strong></td>
<td><input name="requiredcountry" size="48" type="text"> <font color="#ff0080">*</font></td>
</tr>

<tr>
<td><strong>Email:</strong></td>
<td>
<font color="#006600"><b><input name="requiredemail" size="63" type="text"></b></font> <font color="#ff0080">*</font></td>
</tr>
<tr>
</tr>


<tr>

<td align="left" valign="top"><br></td>
<td><input value="Submit" name="B1" type="submit"> <input value="Reset" name="B2" type="reset"></td>
</tr>
</tbody></table>
<b><font color="#006600"> </font></b></div>
</form>

I saw this script posted by somebody else in this forum
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}

</script>

I have some knowledge of html but not Javascript, I just copy and paste. Please help me to know where and how to add this script in either the head section or body section to make it work.

Thanks a lot in advance,

Regards
Mukhtar
http://fengshuihope.bravehost.com

mukhtar88
07-15-2007, 11:32 AM
Hi,

Does nobody know the answer, I am asking how to add an email filter to the email text box.

Still waiting for somebody to help

Regards,
Mukhtar
http://fengshuihope.bravehost.com

thetestingsite
07-15-2007, 04:13 PM
<script>

/*
Check required form elements script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}

else {

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

var returnval=emailfilter.test(which.requiredemail.value)

if (returnval==false){
alert("Please enter a valid email address.")
which.requiredemail.select();
return false;
}

return true

}

}

</script>

Script in the body section
<form method="post" onsubmit="return checkrequired(this)" enctype="multipart/form-data" action="http://pub32.bravenet.com/emailfwd/senddata.php">
<b><font color="#006600"><input name="usernum" value="2704960386" style="border: 0px solid rgb(0, 0, 0); width: 0px; height: 0px;" type="hidden">
<input name="cpv" value="2" style="border: 0px solid rgb(0, 0, 0); width: 0px; height: 0px;" type="hidden">
<!-- DO NOT CHANGE OR REMOVE THE 3 TAGS ABOVE THIS COMMENT-->
</font></b><div align="left"><label for="thankyou" style="display: none;"><b><font color="#006600">hidden field</font></b></label><b><font color="#006600"><input value="http://fengshuihope.bravehost.com/download1.htm" id="thankyou" name="thankyou" style="border: 0px solid rgb(0, 0, 0); width: 0px; height: 0px;" type="hidden"></font></b><div style="clear: left; height: 20px; display: none;"><b><font color="#006600"> </font></b></div>
<table border="0" cellpadding="0" cellspacing="3">
<tbody><tr>
<td><strong>Name: </strong></td>
<td><input name="requiredname" size="35" type="text"> <font color="#ff0080">*</font></td>
</tr>
<tr>
<td><strong>Country:</strong></td>
<td><input name="requiredcountry" size="48" type="text"> <font color="#ff0080">*</font></td>
</tr>

<tr>
<td><strong>Email:</strong></td>
<td>
<font color="#006600"><b><input name="requiredemail" size="63" type="text"></b></font> <font color="#ff0080">*</font></td>
</tr>
<tr>
</tr>


<tr>

<td align="left" valign="top"><br></td>
<td><input value="Submit" name="B1" type="submit"> <input value="Reset" name="B2" type="reset"></td>
</tr>
</tbody></table>
<b><font color="#006600"> </font></b></div>
</form>


Not tested, but hope this helps.

mukhtar88
07-16-2007, 02:47 PM
Dear thetestingsite,

I do not know your name, but the email code which you set right for me really worked and perfect.

Thanks a lot to you and for your kind help.
God bless you.

Regards,
Mukhtar
htpp://fengshuihope.bravehost.com
http://mukhtar.forumup.com
(Feng shui forum)