Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 5 of 5

Thread: Contact Form Required Fields not working

  1. #1
    StoreBuilder is offline Junior Member
    Join Date
    Oct 2010
    Posts
    9

    Default Contact Form Required Fields not working

    On my site the contact form has * next to required fields by default however a user can just click submit to send the form and I get a blank email.

    When needs to be done to make these required fields required?

    I am using version 8.

  2. #2
    ASPAlfred is offline Senior Member
    Join Date
    Nov 2007
    Posts
    2,244

    Default

    Please make a full backup of your DB and run the script below.

    Code:
    UPDATE [dbo].Topic
    SET Description = 'This is the topic Named: contact. You edit this in the ADMIN site. Your Store Name<br/>Address1<br/>Address2<br/>City, State Zip<br/>Phone: xxx-xxx-xxx<br/>FAX: xxx-xxx-xxx<br/>E-Mail: sales@yourdomain.com<br/><br/><hr size="1"/><b>Or, use the form below to send us a message</b><br/><br/><form id="MailArea" method="POST" action="sendform.aspx"><div><script type="text/javascript">function CheckFields(){var ergx = new RegExp(''\\w+([-+.\'']\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*''); if(document.getElementById("MailName").value == "" || document.getElementById("MailPhone").value == "" || document.getElementById("MailEmail").value == "" || document.getElementById("MailSubject").value == "" || document.getElementById("MailMessage").value == ""){alert("Please complete entries.");return false;} if(!ergx.test(document.getElementById("MailEmail").value)){alert("Invalid Email.");return false;}}</script></div><div align="left"><table border="0" cellpadding="0" cellspacing="0" width="454"><tr><td valign="top" align="right" width="102">*Your Name:</td><td valign="middle" align="left" width="348"><input type="text" Name="Name" size="27" id="MailName"></td></tr><tr><td valign="top" align="right" width="102">*Your Phone:</td><td valign="middle" align="left" width="348"><input type="text" Name="Phone" size="27" id="MailPhone"></td></tr><tr><td valign="top" align="right" width="102">*Your E-Mail:</td><td valign="middle" align="left" width="348"><input type="text" Name="EMail" size="27" id="MailEmail"></td></tr><tr><td valign="top" align="right" width="102">*Subject:</td><td valign="middle" align="left" width="348"><input type="text" Name="Subject" size="27" id="MailSubject"></td></tr><tr><td valign="top" align="right" width="102">*Message:</td><td valign="middle" align="left" width="348"><textarea rows="11" Name="S1" cols="41" id="MailMessage"></textarea></td></tr><tr><td width="102"></td><td width="348"><input type="Submit" value="Submit" Name="B1" onclick="return CheckFields();"></td></tr></table></div></form>'
    WHERE Name = 'contact'
    * if you've customized the contents of your "contact" topic already, make a backup first by renaming it to 'contactbak' in the Topic Manager's page in the admin before running the above script. Otherwise, your existing contact topic will be overwritten.

  3. #3
    StoreBuilder is offline Junior Member
    Join Date
    Oct 2010
    Posts
    9

    Default

    I see what is happening. It seems every time I go in and edit the "contact" topic it strips out the javascript used for the form. I end up with and empty div where the javascript was.

    How can I keep the javascript in place after making changes?

    Traci

  4. #4
    AspDotNetStorefront Staff - Scott's Avatar
    AspDotNetStorefront Staff - Scott is offline Administrator
    Join Date
    Mar 2007
    Location
    Ashland, OR
    Posts
    2,390

    Default

    You'll need to follow the steps in this KB article.

  5. #5
    StoreBuilder is offline Junior Member
    Join Date
    Oct 2010
    Posts
    9

    Default

    Thanks, that helped. Now the javascript stays in place however the form is not working.

    Here is a link to the page, and as you can see you are not able to click the submit button. (I have tried in multiple browsers)

    You are however able to place your curser in the name field and tab down to the submit button and press the enter key. The form the still submits successfully, and its empty, so the required field features is still not working.

    I must be missing something else.