p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   Classic ASP email not working in Chrome? (http://p2p.wrox.com/showthread.php?t=81264)

sdagger October 15th, 2010 01:12 PM

Classic ASP email not working in Chrome?

I have programmed many sites in asp using the cdosys and cdo.message for contact forms etc. I am now finding that none of the forms are working in chrome? they have worked fine in IE, Firefox etc but not in chrome. Can anybody help as to why this may be and is there a fix I can do? I have about 15 sites using similar code to the below which works in most browsers. Why would chrome treat this code different?

Many thanks for anyone who can help me solve this problem. The code I know works is:

Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="auth.smtp.domain. co.uk"
objConfig.Fields(cdoSendUserName) = "username"
objConfig.Fields(cdoSendPassword) = "password"

'Update configuration
Set objMail.Configuration = objConfig
objMail.From = Request("email")
objMail.To = "somemail@somemail.co.uk"
objMail.Subject = "some subject"
objMail.TextBody = "some text"

kushalkg October 15th, 2010 01:51 PM

The asp code doesn't run in browser. It merely passes submit request to server where this code runs. You may want to verify if chrome is submitting the request to web server.

Also, what error you are seeing?


sdagger October 15th, 2010 01:57 PM

Classic ASP email not working in Chrome?
That what is confusing me. I know asp runs serverside so why would Chrome treat it all differently?

I don't get an error message, when I submit, it merely just blanks all input fields and remains on the same page. I have code that simply does a response.redirect to a comfirmation page which is fine in IE and Firefox and has been for years.

I'm confused.

sdagger October 15th, 2010 02:00 PM

If it is possibly the javascript validation is not working then maybe this is why chrome does not like it. Here is the clientside validation I am using to check user entries prior to submission:

<script type="text/javascript">
function checkForm(theForm) {

if (theForm.elements['firstname'].value == '') {
alert('You must enter your First name.');
return false;
if (theForm.elements['surname'].value == '') {
alert('You must enter your Surname.');
return false;
if (theForm.elements['contactnumber'].value == '') {
alert('You must enter your contact phone number.');
return false;
if (theForm.elements['email'].value == '') {
alert('You must enter an email address.');
return false;
if (theForm.elements['enquiry'].value == '') {
alert('You must enter your enquiry details.');
return false;


Old Pedant October 15th, 2010 02:10 PM

Where are you calling checkForm( ) from???

If you are calling it from your <form onsubmit="return checkForm(this);"> then you are making a HUGE mistake. You are just lucky the code has worked in other browsers.

If you are doing that, then you *MUST* change your document.contactform.submit() at the end of the function to simply return true;

If that's not what you are doing, show the actual place it is called.

sdagger October 15th, 2010 02:15 PM

I am calling the function from the following:

<form name="contactform" action="contactus.asp" method="post">

Form inputs here then...

<input class="button" type="submit" name="action" value="Submit Enquiry" onClick="javascript:return checkForm(document.contactform);" />

Old Pedant October 15th, 2010 02:25 PM

Same thing, then.

Either change the JS code to just do return true or change the <input> from type="submit" to type="button"

Also, you should never name a form field "submit" or "action" or "method" as those names *HIDE* the properties of the same name in the <form> tag. May not matter in this case, just a bad practice to get into.

sdagger October 15th, 2010 02:42 PM

Fantastic. Thanks Old Pedant. you nailed it!!!!

It was just a case of adding return true; to the javascript function just before the document.contactform.submit(); in the validation.

Thank you millions!!


All times are GMT -4. The time now is 08:53 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.