So I have a wordpress site and I have a contact form that I send with jquery ajax function, and so on. The validation stuff works fine and so on, but I want that the input fields will clear when user clicks the submit button, if the form is sent.
So here's my code for the sending:
$(function() {
$('.error').hide();
$("#Submit").click(function() {
// validate and process form here
$('.error').hide();
var Nimi = $.trim($("input#Nimi").val());
if (Nimi == "") {
$("label#nimi_error").show();
$("input#Nimi").focus();
return false;
}
var Puhelin = $.trim($("input#Puhelin").val());
if (Puhelin == "") {
$("label#puhelin_error").show();
$("input#Puhelin").focus();
return false;
}
var Sahkoposti = $.trim($("input#Sahkoposti").val());
if (Sahkoposti == "") {
$("label#sahkoposti_error").show();
$("input#Sahkoposti").focus();
return false;
}
});
});
var dataString = $('#knamecontactform').serialize();
The code checks for every input field if it's empty or not, and if first is empty, it shows the first error, if the second is empty, it shows the second error, one error at a time.
If it's sent, it will fade a message saying "Message sent" but the input fields are still containing the information, and user can spam using the submit button. What do I need to write to the success: function(){}
part that the inputs are cleared?
EDIT: Dreamweaver is also saying that it has a syntax error... But I can't locate it.
But it's not working. What's wrong with it? I'm trying to achieve the possibility to select me as a recipient from a contact form but only from a specific option.
I'm building a website. I've created the pages to work without page loads, and by clicking a link from the navbar, the content slides up and the new content slides visible. But, I can't link to any page, it always goes to the first page. I've tried this hashchange thing, and I can't get it working. But I need to get the linking work. Can anyone help?