[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.0

html email using asp

Asked by elmbrook in Active Server Pages (ASP), JavaScript, Hypertext Markup Language (HTML)

Tags: asp, html, javascript

Hi experts,

I have a problem with the validation.
I try to send an email in html form using asp CDO and doing the validation of the form using javascript

but it seems that my code did now work for the validation

here is my html page

<html>
<head>
<script src="validate.js" type="text/javascript"></script>
</head>
<body>
<form method="post" name="frmcontact" action="mailsend_contact.asp" onsubmit="return validateForm(this, 'contactus');">
<table width="427">
      <tr>
            <td width="92" style="width: 92px">Name:</td>
            <td width="249"><input name="txtName" type="text" class="text" style="width: 280px; height:20px" id="txtName" /></td>
      </tr>
      
      <tr>
            <td style="width: 92px">Email:</td>
            <td><input name="txtEmail" type="text" class="text" style="width: 280px; height:20px" id="txtEmail"/></td>
      </tr>
      
      <tr>
            <td style="width: 92px">Phone:</td>
            <td><input name="txtPhone" type="text" class="text" style="width: 280px; height:20px"id="txtPhone" /></td>
      </tr>
      
      <tr>
            <td valign="top" style="width: 92px">Message:</td>
            <td><textarea name="txtMsg" cols="20" rows="1" class="text" style="width: 280px; height: 117px" id="txtMsg"></textarea></td>
      </tr>
      
      <tr>
            <td width="92px" height="><span class="greentext">*</span> = Mandatory Field</td>
            <td width="280px"><input name="Button1" type="submit" class="submit" value="Submit" /></td>
      </tr>
</table>
</form>
</body>
</html>

and here is the asp code

<%

redirect= "thankyou.htm"

'Gather input information
'=========================================
contactname       = Request.Form("txtName")
emailaddr             = Request.Form("txtEmail")
phone                   = Request.Form("txtPhone")
message             = Request.Form("txtMsg")

'Find out the email type
emailto   = "seaman117@gmail.com"
emailsubj = "Seafood Restaurant Contact Form - " & contactname

'Form html body
'===========================================
html       = ""
html       = html & "Name:      " & contactname & vbcrlf 'vbcrlf = new line
html       = html & "Email:      " & emailaddr & vbcrlf
html       = html & "Phone:      " & phone & vbcrlf & vbcrlf
html       = html & "Message:" & vbcrlf & vbcrlf & message

if contactname<> "" and emailaddr <> "" and message <> "" then

'Send email
'==========================================
Dim ObjSendMail
Dim iConf
   
Set ObjSendMail = Server.CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set ObjSendMail.Configuration = iConf

ObjSendMail.To             = emailto
ObjSendMail.Subject = emailsubj
ObjSendMail.From       = emailaddr
'ObjSendMail.BCC            = ""
   
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = html
   
ObjSendMail.Send
   
Set ObjSendMail = Nothing

Response.Redirect(redirect)

end if

%>


i can send the email but when i try to leave empty the required field, it should show a pop up

but my code is keep send the email and the javascript validation does not seems work.

thank you,




1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
function validateForm(theform, formname)
{
	pass = 1; //assume everything is ok
	msg = "The following problem was found in trying to submit this form:\n\n";
	
	
	//Check enquiry form or contact us form
	//======================================
	if (isEmpty(theform.txtName.value))
	{
		msg = msg + "- Name cannot be empty\n";
		pass = 0;
	}
 
			
	//make sure required fields are not empty
	if (isEmpty(theform.txtEmail.value))
	{
		msg = msg + "- Email address cannot be empty\n";
		pass = 0;
	}
	else
	{		
		//validate the email address
		if (!(isEmail(theform.txtEmail.value)))
		{
			msg = msg + "- Please enter a valid email address\n";
			pass = 0;
		}	
	
	if (isEmpty(theform.txtMsg.value))
	{
		msg = msg + "- Message cannot be empty\n";
		pass = 0;
	}
	
			
	
	if (pass == 1)
	{
		return true;
	}
	else
	{
		alert(msg);
		return false;
	}
}
 
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}
 
function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
 
//Check whether it is numeric value or not
//e = event
function AllowNumber(e)
{
	var keyCode = (isNetScape) ? e.which : e.keyCode;
	var ckey =  String.fromCharCode(keyCode);
	
	for (i=0; i<filter.length; i++)
	{
		if (filter[i] == ckey)
			return true;
	}
		
	return false;
}
[+][-]09/15/09 04:40 AM, ID: 25333760Accepted Solution

Your question has an Asker Certified™ answer! elmbrook verified that this solution worked for them--which means it will likely work for you, too. Click to view the solution free for 30-days now.

About this solution

Zones: Active Server Pages (ASP), JavaScript, Hypertext Markup Language (HTML)
Tags: asp, html, javascript
Sign Up Now!
Solution Provided By: carrzkiss
Participating Experts: 2
Solution Grade: A
 
[+][-]09/14/09 07:47 PM, ID: 25331301Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/14/09 07:56 PM, ID: 25331343Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/14/09 08:55 PM, ID: 25331584Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/14/09 09:23 PM, ID: 25331711Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/14/09 09:25 PM, ID: 25331719Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/15/09 09:15 AM, ID: 25336504Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/15/09 02:49 PM, ID: 25339980Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/15/09 04:56 PM, ID: 25340708Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20100308-EE-VQP-132 - Hierarchy / EE_QW_3_20080625