hi! I have problem with my jquery validation. When I successfully submitted my form, the value i enter is still there in the <input:text>. It supposed to be refresh and the form is emptied.

here's my jquery code

// JavaScript Document
	 $(document).ready(function(){
	 
	 $("#myformcom").submit(function(){
	 		
			var str=$(this).serialize();
			//var result;
			
			$.ajax({
			type: "POST",
			url: "submitcomment.php",
			data: str,
			success:function(msg)
			{
			
				$("#error").ajaxComplete(function(event,request,settings)
				{
				
					if(msg=='Successfully Submitted')
						{
							$(this).html(msg);
														
						}
					else{
							$(this).html(msg);
						}
						
					
						return true;			
				});
				
			}	
			});
			
			return false;
	 });
	 });

how can i refresh my page when it is successful?

Is there a reason you want to refresh the page, or do you just want to clear the inputs ? You can use jquery do do it.

$('input').each(function() { $(this).val(''); });

yes i want to clear the input. i will try your code when i'm home.

hi! the code that you gave me was not working. i try it yesterday. the same result, the value is still there.

How about this one, this works on my form:

$('input').attr('value', '');

hi! your previous code that you give is now working. thanks to you. The reason why it didn't work in my first attempt because of the space in my submitcomment.php file. Thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.