Trouble with submit button after error message

I’m error testing a contact form, after submitting the form the submit button will not work again.

The code works fine for each error the trouble seems to be the submit button only works once.

I would like to display the error, and let the user continue with the form and submit again.

my troubled form is at http://www.flinderstrees.com.au/contact.htm

Any help would be appreciated.

Also im using the exact code on another page that works fine, http://www.prolificpixel.com.au/contact.html can,t figure it out.

the code is as follows:

<?php
session_start();
$name = $_POST[‘name’];
$email = $_POST[‘email’];
$phone = $_POST[‘phone’];
$comment = $_POST[‘comment’];
$submit = $_POST[‘submit’];
$security_code = $_POST[‘security_code’];

$error = “Please enter a valid email” . ‘<br />’;
$max = 10;
$toManyNum = “Please enter 10 numbers or less” . ‘<br />’;
$req = “Please enter required fields!” . ‘<br />’;
$typeCode = “Please type in the code” . ‘<br />’;
$wrongCode = “Wrong code” . ‘<br />’;

if(!eregi(“[1]+([_\\.-][a-z0-9]+)" .“@”."([a-z0-9]+([\.-][a-z0-9]+))+”.“\\.[a-z]{2,}”.“$”,$email ))
{
echo $error;
}
if($name == NULL)
{
echo $req;
}
if( strlen($phone) > $max )
{
echo $toManyNum;
}
if (empty($security_code))
{
echo $typeCode;
}
else if ($_SESSION[‘security_code’] != $security_code && (!empty($_SESSION[‘security_code’])) && (!empty($security_code)))
{
echo $wrongCode;
}
if($_SESSION[‘security_code’] == $security_code && (!empty($_SESSION[‘security_code’])))
{
echo ‘Message sent!’;
}
?>

The jQuery:

// <![CDATA[
jQuery(document).ready(function(){
$(‘#contactform’).submit(function(){
var action = $(this).attr(‘action’);
$.post(action, {
name: $(‘#name’).val(),
email: $(‘email’).val(),
phone: $(‘#phone’).val(),
comment: $(‘#comment’).val(),
security_code: $(‘#security_code’).val()
},
function(data){
$(‘#contactform #submit’).attr(‘disabled’,‘’);
$(‘.response’).remove();
$(‘#contactform’).before(‘<p class=“response”>’+data+‘</p>’);
$(‘.response’).slideDown();
if(data==‘Message sent!’) $(‘#contactform’).slideUp();
}
);
return false;
});
});
// ]]>


  1. a-z0-9 ↩︎

your form’s action is set to contact.php.

The problem is probably in there but you haven’t posted its code.

Also, are you disabling the submit button in your jQuery?

Hmmmm…

Thanks starLion, it’s staring me in the face.

I must say I did notice it but the fact that it is not affecting the first
form I used the script on, confused me.

I have removed it from the form that wouldn’t work and it is fine now. I need to understand
why the same code and script isn’t disabling the submit button on the first form I did.

Any ideas would be most helpful.