Possible Duplicate:
Can't clear the input value after form is submited
Ok, so I tried a 100 times. I need to clear input data after validation and submitting the form. Then the wrapper div will fade out. So, validate, submit, clear data, fade out. I have a feeling that I don’t put the val(”) in the right place. If anyone wants to help.. thanks.
$(document).ready(function () {
$('#form1').ajaxForm({
beforeSubmit: validate
});
function validate(formData, jqForm, options) {
var name = $('input[name=name]').fieldValue();
var email = $('input[name=email]').fieldValue();
var message = $('textarea[name=message]').fieldValue();
if (!name[0]) {
alert('Please enter a value for name');
return false;
}
if (!email[0]) {
alert('Please enter a value for email');
return false;
}
if (!message[0]) {
alert('Please enter a value for message');
return false;
}
}
var name = $('input[name=name]').val('');
var email = $('input[name=email]').val('');
var message = $('textarea[name=message]').html('');
$("#form1").ajaxForm(function () {
$("#formplic").fadeOut(1000, function () {
$(this).html("<img src='images/postauto2.png'/>").fadeIn(2000);
});
});
});
Remove these lines:
and try this: