Skip to main content
Known Participant
May 5, 2017
Answered

Need help with outdated Contact Form Script

  • May 5, 2017
  • 9 replies
  • 23829 views

Hello,

  I am working with Dreamweaver CS4 - Version 10 - still - and realize it is out of date.  I manage a few websites, and have used Contact form scripts on all the sites which have worked successfully.  The sites are hosted through different companies though.  On one of the sites though, I am having an issue with the Contact form no longer working, and it appears to be a Dreamweaver contact form script that is the problem.  The form no longer Submits or Resets, so there is either something wrong with the script which could be outdated, or it is somehow incompatible with the hosting service's server - but I don't really know. We are using Bluehost.com for hosting, and they don't give technical support for code on websites - they only host - so it is hard to know for sure why my Contact form is no longer working. I have verified that it isn't the email address - which is correctly coded into the submit button script.  I am not sure if it is due to the age of my Dreamweaver program, and the script it generated for the form, so that is why I am posting here.  Below I have copied and pasted the code so someone might take a look and let me know what they think. Dreamweaver inserted an 'onclick="MM_validateForm' script into the Submit button.  This worked before, but maybe it no longer works - but I don't know.  Below I have shown all the coding on the page, for the form, starting with the head section javascript.

In my <head> section of the website page, I have this javascript inserted, to make the form work:

<script type="text/javascript">

<!--

function MM_validateForm() { //v4.0

  if (document.getElementById){

    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args);

      if (val) { nm=val.name; if ((val=val.value)!="") {

        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';

        } else if (test!='R') { num = parseFloat(val);

          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';

          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

            min=test.substring(8,p); max=test.substring(p+1);

            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

    } if (errors) alert('The following error(s) occurred:\n'+errors);

    document.MM_returnValue = (errors == '');

} }

//-->

</script>

And here is the form script I am using in the <body> section of the page, shown below.  The problem seems to occur with the Submit button, which doesn't initiate any action when the form is clicked and nothing happens when either the Submit or the Rest buttons are clicked.

Here is the specific code for both the Submit and the Reset buttons, contained within the overall form code below:

Submit button:

<input name="Submit2" type="submit" onclick="MM_validateForm('firstname','','R','lastname','','R','email','','RisEmail','TextArea','','R');return document.MM_returnValue" value="Submit" class="formbutton" />


Reset button:                  
<input type="reset" value="Reset" name="Reset2" class="formbutton"/>

The complete form code:

<form name="contactform" action="http://www.bluehost.com/bluemail" enctype="multipart/form-data" method="POST">

                             

                                 <blockquote>

                                   <p align="left"><b>

                                     <span class="formtitle"><br />

                                       * First Name:</span></b>

                                     <label>

                                       <input name="firstname" type="text" class="textbox" id="firstname" size="30" maxlength="30" />

                                       </label>

                                     </p>

                                   <p align="left">

                                     <label><span class="formtitle">* Last Name:</span>

                                       <input name="lastname" type="text" class="textbox" id="lastname" size="30" maxlength="30" />

                                       </label>

                                     </p>

                                   <p align="left">

                                     <label><span class="formtitle">Phone:</span>

                                       <input name="phone" type="text" class="textbox" id="phone" size="15" maxlength="15" />

                                       </label>

                                     <label><span class="formtitle">ext.</span>

                                       <input name="extension" type="text" class="textbox" id="extension" size="6" maxlength="6" />

                                       </label>

                                     <br />

                                     <br />

                                     <b><font color="#6699ff"

              size="2"

              face="Verdana, Arial, Helvetica, sans-serif" class="formtitle">* Email:</font></b>

                                     <label>

                                       <input name="email" type="text" class="textbox" size="25" maxlength="25" id="email" onblur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" />

                                       </label>

                                     </p>

                                   <p align="left"> </p>

                                   <label name="checkbox">

                                   </label>

                                   <p align="left"><br />

                                     <b><font color="#6699ff" size="2" face="Verdana, Arial, Helvetica, sans-serif" class="formtitle">Questions/Comments:</font></b><br />

                                     <br />

                                     <textarea name="TextArea" cols="40" rows="8" wrap="virtual" class="textbox" id="TextArea"></textarea>

                                     </p>

                                   <p align="left">

                                     <input type="hidden" name="sendtoemail" value="me@myemail.com" /> [removed personal email address - Mod]

                                     <input type="hidden" name="redirect" value="http://www.cjvolk.com/thankyou.html" />

                                     <input name="Submit2" type="submit" onclick="MM_validateForm('firstname','','R','lastname','','R','email','','RisEmail','TextArea','','R');return document.MM_returnValue" value="Submit" class="formbutton" />

                                     <input type="reset" value="Reset" name="Reset2" class="formbutton"/>

                                     </p>

                                   <p> </p>

                                   </blockquote>

                                 </form>

If someone can please tell me - is this a Dreamweaver code problem, where the code is out of date for the browsers now, or could it be some other issue?  Does anyone have a suggestion, since I am using an older version of Dreamweaver as to the best way to update this code?

I appreciate anyone's input or answers - hope to get some help soon!  Thank you very much!

Jackie

This topic has been closed for replies.
Correct answer osgood_

The form submit and reset buttons are working.

All you need do to test this is create a new DW document and insert the form code plus the <script></script> code.

There must be something else on your page stopping the form buttons working. Can you link to the actual page in question then maybe someone can take a more indepth look at what that could be.

EDITED: Submit and reset buttons are work on your  contact page:

CJVolk Associates - Treasury and Cash Management Consulting Services

Edited: Ok maybe they are not - seem to be a bit hit and miss

9 replies

Participant
August 20, 2019

I realize this is pretty old, but when I dealt with this issue, the only problem was that the form action URL http://www.bluehost.com/bluemail​ needed to be changed to https at the beginning. (I didn't get an email from them when they changed that...)

The only reason I'm posting about this now is that address gives a 404 error. This page comes up when looking for BlueHost mail script-related answers. I'll update this whenever I get new information.

SG-22
Participant
August 22, 2017

I was in online chat with Bluehost tech support a little while ago. They have quit supporting that wonderful snippet of code that worked so well.

I simply wrapped it around the email form I set up about 2 years ago after fighting with my form to get it talk to Bluehost.

It really is a shame the snippet has been disabled by Bluehost and Bluemail. It really was a fantastic little bit of code.

Nancy OShea
Community Expert
Community Expert
August 22, 2017

What does Bluehost recommend you use now?

Does your server support PHP and the PHP mail() function?

Nancy O'Shea— Product User & Community Expert
SG-22
Participant
August 23, 2017

Actually, I checked the Bluemail website where they provided directions for continuing to use their script at Bluehost. The solution is found by clicking on the </> Script (CGI) button in C-Panel after signing into your Bluehost C-Panel.

Once that opens, Bluemail is still there and functioning. I selected "generate code" and it still generates the wonderful script it did before that wraps around your selected Dreamweaver options for the form. I did notice some updates to it that take advantage of coding improvements of the last few years.

Bluehost recommended checking into services that generate contact forms, but those were all for CRM (Contact Relationship Management) and didn't serve my purpose.

I have to finish customizing the script, but I'm quite happy Bluemail is still supporting activities with Bluehost. Next idea - adapt the script for use with the other hosting service I deal with, Gridhoster. Unfortunately, Gridhoster doesn't have the handy code generator for contact forms. Keeping my fingers crossed that it works as smoothly as it used to and can be adapted to Gridhoster's mail system.

I also stumbled on a Bootstrap site, http://bootstrapious.com. They offer templates and user guidance. One was a contact form and one was a blog layout I really liked. So, I downloaded some of their templates and a "cheat sheet" of sorts. I still have to open the zip files but within 24 hours of signing up for their newsletter and downloading a collection of their templates, I heard from the site owner to inquire as to whether the template was what I was looking for and whether I needed any assistance customizing the templates to my needs.

Known Participant
May 11, 2017

Here is a good page on the @W3Schools website, about how to use the various attributes:

HTML Input Attributes

It says:

The pattern Attribute

The pattern attribute specifies a regular expression that the <input> element's value is checked against.

The pattern attribute works with the following input types: text, search, url, tel, email, and password.

Tip: Use the global title attribute to describe the pattern to help the user.

Tip: Learn more about regular expressions in our JavaScript tutorial.

Example

An input field that can contain only three letters (no numbers or special characters):

Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code">

Too bad they don't give an example for telephone numbers!

Known Participant
May 11, 2017

Thursday, May 11, 2017 at 5:36 p.m.

Hi again, all -

Sorry I did not reply sooner - I have been super busy and had to put this on hold for a few days.  But I have read all of your helpful posts, and really appreciate the advice, and thank you for all of the helpful advice regarding phone numbers and emails.  I think the best option is to make the phone number field optional (1) as you first suggested, then to make it an input type="text".  What I am having a bit of trouble understanding is if I should be using both a value and a placeholder, for each field.

(Problem #2)  the PHP script doesn't work with my form...
After working on building out this form in HTML5, (and changing my HTML page to a <!Doctype="html">)
, I tried unzipping the PHP form builder that I had downloaded - a free one that I found online.  It comes with an admin panel, where you set all the fields, etc.  So I have activated the installation of it - which went fine; then started inserting a javascript code in the <head> area, as well as another PHP script in the body, where the form is supposed to appear.  You can have more than one form on your page, but have to number them. Plus, there are numerous other settings in the admin panel, which I am trying to figure out still.  Some of them are obvious, others are not.  It also comes with a captcha.  Here's the problem - the form that I built out, using Nancy's HTML 5 format she posted earlier, does not work now with this PHP script I have downloaded.  It is supposed to generate it's own form, the fields for which are controlled and inserted through the admin panel.

I want to  use the form that I built with the basic HTML 5 code that Nancy originally helped me with that I have worked with and show below, but I don't know how that can be done with this PHP form builder script.  So do I look for another type of PHP script to get my form working?  If so, I am not sure where or what I need to look for, that can be used in connection with the HTML 5 form I built out - which I show the code for below.

   My form has progressed a bit since I was last here on the forum talking to all of you, so now the code looks like this:

<form method="post" action="FORM_PROCESSING_SCRIPT_GOES_HERE.php">

                   <blockquote>

                     <p align="left">
<label for "Fullname">

<span class="formtitle">* Full Name: </span>

</label>

                       <input type="text" id="name" name="name" value="enter first and last name" placeholder="First & Last Name" required="required" class="textbox"/>

                       <label for="phone">                 

                       <br /><br>

                      <br>

                       <span class="formtitle"> Phone:</span>

                       <input type="text" id="phone" name="phone" value="~ phone is optional ~"     placeholder="123-456-7890" class="textbox" />

                       </label>

                       <br />

                       <br />

                    

                       <label for="email">

                       <span class="formtitle">

                      <br />

                      * Email Address:</span>

                       </label>

                       <input type="email" id="email" name="email" placeholder="youremail@email.com" value="enter your email" class="textbox" required/>                   

                     </p>

                        <label for="message">

                          <div align="left"><br />

                            <br />

                            <br />

                            <span class="formtitle">                       

                              * Questions and Enquries:</span>

</label>

                            <p align="left" class="textbox">

           <textarea id="message" name="message" cols="40" rows="8" wrap="virtual" class="textbox"
            required />                          

                             </textarea>

                           </p>

                             <br />

                             <br />

                             <input type="submit" value="Submit" id="submit" class="formbutton" /></button>

                             <input type="reset" value="Reset" name="Reset" class="formbutton1"/>

                             <br />

                             <br />

                             </p>

                         </blockquote>

               </form>

Finally, I am also trying to determine if the code above is correct.   For example, can you use both value and placeholder on all of these fields?
I tried using placeholder text in the Comments/Questions textarea, and it did not seem to work to have auto generated text in there.  Also, when you say "required" what is the proper way to use that in the code?  For example, is this correct to have required="required"? :

<input type="text" id="name" name="name" value="enter first and last name" placeholder="First & Last Name" required="required" class="textbox"/>


Or should it just be this  - as it appears in my email field:

<input type="email" id="email" name="email" placeholder="youremail@email.com" value="enter your email" class="textbox" required/>

You can see how the browser is displaying all of this here, on my practice page:   CJVolk Associates - Treasury and Cash Management Consulting Services          

Many thanks again to all of you for your help.  I was busy for a couple of days, and could not get back to this.  I know you're busy too - so I will check back in a little while, or wait to hear from someone.  Thank you again for helping me with this!

pziecina
Legend
May 6, 2017

Whilst not specific to your problem, do remember that the more information you collect from a user, the more you have to protect that information.

Most countries have some form of data protection act. This means that you or your client is responsible for protecting that information, no matter how it is used or how it is stored. There is also no minimum amount of information before it is covered by the data protection laws, 1 or a 1001+ .

Known Participant
May 6, 2017

Thanks again everybody, and Nancy latest.  Thanks for explaining the placeholder, autofocus, required and pattern.  It might be a nice idea to use pattern with the phone field, since that should be all numbers, but again, am not sure how to implement it.  I looked at the link you showed.  They give examples for passwords and country codes, but not phone numbers. 

How would you do a pattern for a phone number?  Not that I necessarily need it - the placeholder is good too, but I thought it might be useful, so somebody doesn't put in bogus text or something like that.

They gave an example for a password, using six or more characters.  Could this be used for a phone number?

   Password: <input type="password" name="pw" pattern=".{6,}" title="Six or more characters

Legend
May 6, 2017

Do not force a user to supply a phone contact number unless you are selling something via your site. Its highly likely to annoy the user to be required to provide a telephone number as they are fearful of cold calling.

None of the information you  gather from your form is guaranteed to be correct - a user can send what they like, hopefully some of it will be good enough for you to do something with.

I would just check to see if at least a valid email address has been provided, plus a name and enquiry. Leave fields like phone numbers to the disgression of the user unless its required in the example of a user having purchased a product in which case the user will most likely have no objection to providing their phone number.

Nancy OShea
Community Expert
Community Expert
May 6, 2017

If your phone numbers go into a database, then setting some restrictions is probably a good idea.  International phone number pose a major obstacle for some programmers where you might encounter an input field with this:  011 +1 (123) 456-7890 x20

<input type="tel" restricts input to numerals.  BTW it's also great for US zip codes.

If the Tel field is not required (and in most cases it shouldn't be), I would just let them put whatever they want into it with a character minimum of 10 (US area code + phone number).

<input type="text"

Nancy

Nancy O'Shea— Product User & Community Expert
Legend
May 5, 2017

On further investigation of the code you are missing a closing " (see in red below AFTER #428284; )

<td width="448" height="483" bgcolor="#CEDDFD" style="border: 1px solid #428284;"><form name="contactform" action="http://www.bluehost.com/bluemail" enctype="multipart/form-data" method="POST">

That should solve the problem.

BUT as Nancy has pointed out this is a cheap and cheerful script which leaves the email address wide open to spam harvestors. Its up to you - if its been serving you well and you have  had little problems then no need to change but if spam has been an issue in the past then consider using a more secure script.

Known Participant
May 5, 2017

Hi again, Osgood,

I did notice that missing " and had inserted that.  I can see it on my end, but maybe I forgot to upload the corrected version.  I will do that now.  Thank you again.

Jackie

Nancy OShea
Community Expert
Community Expert
May 5, 2017

I can't sugar coat this.  The code is awful.  And if that's not bad enough, it commits the evilest of sins by not concealing the email address from robots and spammers.    There's nothing here I would salvage.

Use a plain vanilla HTML5 form with self-validating fields.  Find out from Bluehost which server-side scripts you can use with this hosting plan.  Hopefully the plan supports PHP scripts.

Below is a plain HTML5 form.

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>HTML5 Form</title>

</head>

<body>

<form method="post" action="FORM_PROCESSING_SCRIPT_GOES_HERE.php">

<div>

<h4>Text Field</h4>

<label for="name">Name: <span class="required">*</span> </label>

<input type="text" id="name" name="name" value="" placeholder="First & Last" required="required" autofocus />

</div>

<div>

<h4>Email Field</h4>

<label for="email">Email Address: <span class="required">*</span> </label>

<input type="email" id="email" name="email" placeholder="yourname@email.com" required/>

</div>

<div>

<h4>Text Area</h4>

<label for="message">Message: <span class="required">*</span> </label>

<textarea id="message" name="message" placeholder=" your message here." required></textarea>

</div>

<div>

<input type="submit" value="Submit" id="submit"/>

</div>

</form>

</body>

</html>

At a minimum, your server-side script must conceal the email address, sanitize data, thwart spambots and send data to your email.

Nancy

Nancy O'Shea— Product User & Community Expert
Known Participant
May 5, 2017

Thank you so much, Nancy.  I have been responding to Osgood, but really appreciate your input.  I am going to get rid of this old code and update to an HTML5 form code. Thank you so much for your suggestion, and for the suggestion of using the PHP. 

As I just mentioned to Osgood, this is an older website and I had not updated it in a long time.  So it shows!  You are absolutely right about the email being visible - not good!  I am aware of the issue, but I don't know PHP, so probably didn't know how to implement a better solution at the time I built this website.

Thank you so much - I really appreciate your help, and I will keep both of you posted on the progress when I can get the form code and script updated.  You are very nice to reach out and answer my question!

I have to go somewhere so will have to check back in later.  In the meantime, thanks again and I will let you both know how things work out!  : )))

In appreciation,
Jackie

osgood_Correct answer
Legend
May 5, 2017

The form submit and reset buttons are working.

All you need do to test this is create a new DW document and insert the form code plus the <script></script> code.

There must be something else on your page stopping the form buttons working. Can you link to the actual page in question then maybe someone can take a more indepth look at what that could be.

EDITED: Submit and reset buttons are work on your  contact page:

CJVolk Associates - Treasury and Cash Management Consulting Services

Edited: Ok maybe they are not - seem to be a bit hit and miss

Known Participant
May 5, 2017

Thanks Osgood.  I think there is an issue with the Submit and Reset buttons, but don't know what.

However, looks like Nancy answered and may have found more issues with the code itself, so I probably need to just scrap this old code and do a big update.

Thank you very much for taking a look at it.  I will keep everyone posted on the progress.  I have to go out this evening, so won't be able to check back in until maybe tomorrow.  But in the meantime, really appreciate your help!

Jacie