There is a form. Just as I did not try to use the reset-no sense. Any error, or the form is not cleared. How can I clear all the fields inside the form?
Here is the code:
jQuery('#contact-form').submit(function(e) { e.preventDefault(); var c_name = jQuery('#c_name').val(); var c_email = jQuery('#c_email').val(); var c_message = jQuery('#c_message ').val(); var response = jQuery('#contact-form .ajax-response'); var formData = { 'name': c_name, 'email': c_email, 'message': c_message }; if ((c_name == '' || c_email == '' || c_message == '') || (!isValidEmailAddress(c_email))) { response.fadeIn(500); response.html('<i class="fa fa-warning"></i> Исправьте ошибки в форме и попробуйте снова.'); } else { jQuery.ajax({ type: 'POST', // define the type of HTTP verb we want to use (POST for our form) url: 'php/contact.php', // the url where we want to POST data: formData, // our data object dataType: 'json', // what type of data do we expect back from the server encode: true, success: function(res) { var ret = jQuery.parseJSON(JSON.stringify(res)); response.html(ret.message).fadeIn(500); } }); response.html('<i class="fa fa-warning"></i> Ваше сообщение отправлено, Спасибо за Ваш Выбор!'); } return false; });
I tried after sending to contact # contact-form, but nothing comes out.