/    Sign up×
Community /Pin to ProfileBookmark

MSN Users Form Results Never Received

I had someone write some ASP and Javascript for our nonprofit Web site. It uses CDO to send the form results, and puts the in users email address [as the return address] using [in part]:

‘objCDOSYSMail.From = Request(“email”)’

The JS that validates is [in full]:

<SCRIPT LANGUAGE=”JavaScript”>
function emailCheck(fld)
{
// first, trim the email text:
var email = fld.value.replace(/^s+/,””).replace(/s+$/,””);

var re = /^([a-z][w-‘=]+.)*[a-z][w-‘=]+@([a-z][w-‘=]+.)+[a-z]{2,6}$/i
if ( ! re.test( email ) )
{
alert(“Please enter a valid email address”);
fld.focus( );
return false;
}
return true;

}
function checkPwd(fld)
{
var pwd = fld.value.replace(/^s+/,””).replace(/s+$/,””);
if ( pwd == “” )
{
alert(“You did not type the characters into the security box.”);
fld.focus( );
return false;
}
return true;
}
function validate(frm)
{
if ( ! emailCheck( frm.email ) ) return false;

if ( ! checkPwd( frm.pwd ) ) return false;

// other validation
return true;

}
</SCRIPT>

And the form field is [in part]:

<td><form name=”newsletter” method=”post” action=”newsletter.asp” onSubmit=”return validate(this);”>
<input type=”hidden” name=”_FROM_PAGE” value=”newsletter.asp”>
<table width=”100%” cellpadding=”0″ cellspacing=”0″>
<tr>
<td><table width=”100%” cellpadding=”0″ cellspacing=”0″>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”585″><div align=”left”><span class=”style10″> Please provide your email address:</span>&nbsp;
<input name=”email” value=”<%=Trim(“” & Request(“email”))%>” size=40>

It all works fine except I don’t receive any results from MSN or Hotmail users [at least those are the 2 I’m aware of]. I’ve removed this line:

var re = /^([a-z][w-‘=]+.)*[a-z][w-‘=]+@([a-z][w-‘=]+.)+[a-z]{2,6}$/i
if ( ! re.test( email ) )

And, it works. I also know that I can change the CDO to use myaddress as the ‘from’ address, but I’d really like to see who the email is from before I open it. Can someone please help by telling me if I can have it validate and put the users email address in and how?

to post a comment
JavaScript

42 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — If everything works correctly just by removing the validation of the email address format, then that Regular Expression just needs changing. The following email validation Regular Expression might work better:
/^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Hi.

Nope. I tried it, as I've tried a few changes in that line, and nothing. Also, I'm using DreamWeaver, and with the old expression the text is green. When I paste in your script, it's blue, black and red. I'm using ASP - if that matters.

Thanks.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — You used this and got different context-sensitive colors?

var re = /^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Yes. I don't understand that.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — Me, neither. That shouldn't be possible. There's no syntactical difference between what you had and what I gave you.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Okay. I had an idea: If you delete all the domain names that are over 3 letters in length, it's no longer context-sensitive. That's as far as I got in my thoughts.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — Sounds like a DreamWeaver problem.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — LOL. You think? LOL. Still doesn't get me my results. Thanks.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — My guess is that it's reconizing the letters as ASP. It looks the same as my ASP script - the colors - I mean. Grrrr. My hosting company told me it was something to do with that line, but they wouldn't say what.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — With the code I gave you, on what word did the colors change?
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Backspacing from the last domain name (museum), this is how far I got before it changed back to all green:

/^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|i))$/i;
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Looks like if I take any 14 characters out, it stops being context-sensitive.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — Ah. Length limitation?
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — Try this:

var re = new RegExp("^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$", "i");
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — LOL. And you understand that? I wish I did.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — See my second post after that one.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Also, I've found that it's MSN *AND* Hotmail email addresses.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Maybe it's a security issue with the setup of the CDOSYS?
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Keeps alerting me to enter a valid email address.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — Plus, the script color looks okay until it gets to the: ("^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$", "i");

The parenthesis at the beginning and end are bold in blue, and everything in between is light blue.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — This even looks like code I've posted here before ?

var email = fld.value.replace(/^s+/,"").replace(/s+$/,"");

But, I currently write that as follows:

var email = fld.value.replace(/(^s+)|(s+$)/, "");
Copy linkTweet thisAlerts:
@dawgmomauthorJul 04.2006 — nope. still dpesn't work. ?
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — Time to post a live link.
Copy linkTweet thisAlerts:
@phpnoviceJul 04.2006 — That page does not contain the changes I've outlined.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — yes. i changed it back. only thing i didn't keep was the line:

var re = new RegExp("^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$", "i");

because it still isn't all one color
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — i put it up anyway. all your requests for changes are there. sorry. i've been trying all day. just forgot to put the stuff back the way we left it earlier. ?
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — Just because DreamWeaver doesn't know how to color it doesn't mean it won't work in the browser. Give it a try in the browser and let me look at it that way, too.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — i did, and it keeps asking (again) to enter a valid password (even after i do)
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — What email address are you entering for your test?
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — OK, I ran it through my script debugger and found that this:

var re = new RegExp("^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$", "i");

is being evaluated into this (missing backslashes):

var re = /^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;

So, go back to what I gave you originally:

var re = /^w+([.-]?w+)*@w+([.-]?w+)*.(w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — a valid email, i mean
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — okay. still nothing - even with changing it back. i use my hotmail.com account
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — if i use any other account besides my MSN/Hotmail i get the results!
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — I tested the current page and the email address validated just fine.
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — What does a hotmail address look like?
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — objCDOSYSMail.To = "[email protected]"
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — That validates in the JavaScript code, too. So, you must actually be talking about a server-side code problem -- not a JavaScript problem. Try the ASP forum for that problem.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — okay. can i ask what you mean by a 'server-side' code problem?
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — Everything with CDOSYS happens on the server side after the form is submitted. In general:

Errors before the page is displayed are server-side errors.

Errors after the page is displayed, but before the form is submitted are client-side errors.

Errors after the form is submitted are also server-side errors.

This forum is for client-side Javascript errors only.
Copy linkTweet thisAlerts:
@dawgmomauthorJul 05.2006 — okay. thanks for all your help. i really appreciate it. ?
Copy linkTweet thisAlerts:
@phpnoviceJul 05.2006 — No problem.

Cheers.
×

Success!

Help @dawgmom spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...