SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery Form Submission

    My form works as it should and i receive the emails from it but if you hit submit without entering data you get an error box informing you what you of required fields - however my submit button stays greyed out, so even if you then fill in those fields you cannot submit the form without a refresh.

    Code:
    Code:
    jQuery(document).ready(function(){
    	
    	$('#success').hide();
    	$('#contactform').submit(function(){
    	
    		var action = $(this).attr('action');
    		
    		$('#contactform #submit').attr('disabled','disabled').after('<img src="images/ajax-loader.gif" class="loader" />');
    		
    		$("#message").slideUp(750,function() {
    		$('#message').hide();			
    		
    		$.post(action, { 
    			name: $('#name').val(),
    			email: $('#email').val(),
    			phone: $('#phone').val(),
    			subject: $('#subject').val(),
    			comments: $('#comments').val(),
    			verify: $('#verify').val()
    		},
    			function(data){
    				document.getElementById('message').innerHTML = data;
    				$('#message').slideDown('slow');
    				$('#contactform img.loader').fadeOut('fast',function(){$(this).remove()});
    				$('#contactform #submit').attr('disabled',''); 
    				if(data.match('success') != null) $('#submit').hide();
    				
    			}
    		);
    		
    		});
    		
    		return false; 
    	
    	});
    	
    });
    Any help much appreciated!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    You may want to use the .removeAttr() method to remove the disabled attribute.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •