Jump to content

Mail form script Alert - error


Recommended Posts

I’m trying to get the JavaScript Alert to pop up on this mail form script but it just displays a blank page. It submits the form contents fine when the correct spam code is entered.Can anyone tell me what I need to change in the code in order for the JavaScript Alert to pop work?Actual form is here just in case you need to see it in action - rockislandbar.com/formtest.html

 

 

<% ' Define the used variables Dim verCode ' Retrieve the form data verCode = Request.Form("verCode") ' Check if the entered code is the actual code If isCode(verCode) then If Request.Form("submit") <> "" ThenSet myMail=CreateObject("CDO.Message")myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myhost.co.uk"myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""myMail.Configuration.Fields.UpdatemyMail.Subject= "Contact Us From Website" 'This is the subject of the e-mailmyMail.To="my email@mysite.com" 'This is the e-mail address the e-mail will be delivered tomyMail.From=Request.Form("emaddress")myMail.TextBody="Name: " & Request.Form("name") & vbnewline & "E-Mail Address: " & Request.Form("emaddress") & vbnewline & "Message: " & Request.Form("message")myMail.Sendset myMail=nothingResponse.Redirect("thankyou.asp")Else 'Error output%><script language="javascript"><!--window.alert ("It looks like you entered the wrong code rnTry again or click 'Reload for another image' under the image.");window.history.go(-1);//--></script><% End If %> <% ' Function to check if the sent code is the actual verification code Function isCode(enteredCode) ' Check if the entered code in caps is same as the session code (which is in caps) if UCase(enteredCode) = Session("image_ver") then ' Return true isCode = true else 'Return False isCode = false end if End Function End If%>

Link to post
Share on other sites

First, I would remove the HTML comments from the Javascript code (unless you're worried about how Netscape 1 or IE 2 will react). Second, use your browser's developer console to check for Javascript error messages on the page. Is that script tag the only thing the page outputs or is there a complete HTML document there?

Link to post
Share on other sites

No worries, I've fixed it. Moved the Javascript code down to the end of the code:<% ' Function to check if the sent code is the actual verification code Function isCode(enteredCode) ' Check if the entered code in caps is same as the session code (which is in caps) if UCase(enteredCode) = Session("image_ver") then ' Return true isCode = true else %><script language="javascript"> <!-- window.alert ("It looks like you entered the wrong code rnTry again or click 'Reload for another image' under the image."); window.history.go(-1); //--> </script><% 'Return False isCode = false end if End Function End If%>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...