• 0

Contact Form not working in Wordpress


Question

I used this contact form before, but for some reason it's not working correctly on my wordpress site ( http://duddydesign.c...fusion/contact/ ). I use javascript to validate the form. Looks like the javascript isn't running correctly because it shows the alert, but then it submits the form. I used the same script for the contact page @ http://www.tarnishta...ms/contact.html, so idk why it's not working. If someone could help me out it would be greatly appreciated. Thanks.

HTML


<form action="http://duddydesign.comyr.com/DemocracyConfusion/wp-content/themes/NTT-Cindy-Theme/formmail.php" method="post" onsubmit="return FormValidator(this)" id="ContactForm" name="ContactForm">
<input type="hidden" name="recipient" value="xxkmanxx@gmail.com">
<input type="hidden" name="subject" value="Contact Democracy Confusion">
<input type="hidden" name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">
<input type="hidden" name="return_link_url" value="http://duddydesign.comyr.com/DemocracyConfusion">
<input type="hidden" name="return_link_title" value="Back to Democracy Confusion">
<input type="hidden" name="email" value="name@domain.com">

<div id="ContactName"><label>Name:</label> <input type="text" name="UserName" size="48" maxlength="30" class="input"></div><br><br>

<div id="ContactEmail"><label>E-mail:</label> <input type="text" name="UserEmail" size="47" maxlength="40" class="input"></div><br><br>
<div id="ContactWebsite"><label>Website:</label> <input type="text" name="UserWebsite" size="47" maxlength="40" class="input"></div><br><br><br>


<label>To better direct your message, please select below:</label><br><br>

<div id="ContactOtherSubject">
<select class="dropdown" name="Subject" size="1">
<option>- Select One -</option>
<option>Customer Service</option>
<option>Feedback</option>
<option>Other</option>
</select><label> Other:</label> <input type="text" onfocus="return SetOther(ContactForm)" name="OtherSubject" size="25" maxlength="30" class="input"></div>
<br><br>
<label>Enter your comments in the space provided below:</label>
<br><br>
<textarea rows="10" cols="43" name="Comments" class="textarea"></textarea>
<br><br>


<input type="reset" class="button" value="Reset"><input type="submit" class="button" name="Submit_Form" value="Submit">
</form>
[/CODE]

JAVASCRIPT

[CODE]
function FormValidator(theForm)
{

if (theForm.UserName.value == "")
{
alert("Please enter Name.");
theForm.Username.focus();
return (false);

}

if (theForm.Subject.selectedIndex == 0 || (theForm.Subject.selectedIndex != 3 && theForm.OtherSubject.value != ""))
{
alert("Please select a Valid Subject.");
theForm.Subject.focus();
return (false);
}

if (theForm.Subject.selectedIndex == 3 && theForm.OtherSubject.value == "")
{
alert("Please enter Other Subject.");
theForm.OtherSubject.focus();
return (false);
}

if (theForm.Comments.value == "")
{
alert("Please fill in Comment Area.");
theForm.Comments.focus();
return (false);
}

if (theForm.UserEmail.value == "")
{
alert("Please enter E-Mail Address.");
theForm.UserEmail.focus();
return (false);
}



return (true);
}

function SetOther(theForm)
{
theForm.Subject.selectedIndex = 3;
return (true);
}


[/CODE]

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Try using the js inline and after the other js files are loaded, same as on the other site. Sometimes js plays nicely in different orders. I'll take a proper look tomorrow when it's not so late here :)

Link to comment
Share on other sites

This topic is now closed to further replies.