Not clearing the data after form submission in codeigniter php - php

I am having a registration form once user submit the form not clearing the data and it is not displaying the success message as well.here the code which i have written for registration form.
Controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller {
public function __construct() {
parent::__construct();
$this->lang->load('error_messages', 'english');
$this->load->model(VERSION . DOCTOR_MODEL_FOLDER . 'Doctor_model', 'doctors');
$this->load->helper('gmaps');
$this->load->library('locations');
}
public function createAccount() {
$first_name = $this->input->post('first_name');
$last_name = $this->input->post('last_name');
$email = $this->input->post('email_id');
$password = $this->input->post('password');
$phone_number = $this->input->post('phone_number_with_ext');
$reg_no = $this->input->post('reg_no');
$regDetails = array(
'first_name' => $first_name,
'last_name' => $last_name,
'email_id' => $email,
'password' => $password,
'reg_no' => $reg_no,
'mobile_no' => $phone_number,
);
$regMessage = $this->doctors->register($regDetails);
//if registration done successfully
if (is_string($regMessage)) {
$data['success'] = true;
$data['response'] = $phone_number;
} else {
//if there is error
$data['success'] = false;
$data['error_msg'] = $regMessage;
}
die(json_encode($data));
}
View:
<div class="form">
<div class="alert" style="display: none;"></div>
<form class="form-validate form-horizontal " id="register_form" method="post" action="" enctype="multipart/form-data">
<div class="form-group ">
<div>
<input class=" form-control" placeholder="First Name" id="first_name" name="first_name" type="text" />
</div>
</div>
<div class="form-group ">
<div>
<input class=" form-control" placeholder="Last Name" id="last_name" name="last_name" type="text" />
</div>
</div>
<div class="form-group ">
<div>
<input class=" form-control" placeholder="Email Address" id="email_id" name="email_id" type="text" />
</div>
</div>
<div class="form-group ">
<div>
<input class="form-control country-code" placeholder="Phone Number" id="phone_number" name="phone_number" type="tel" />
</div>
</div>
<div class="form-group ">
<div>
<input type="text" class="form-control " placeholder="Registration number" id="reg_no" name="reg_no">
</div>
</div>
<div class="form-group ">
<div>
<input class="form-control " placeholder="Password" id="password" name="password" type="password" />
</div>
</div>
<div class="form-group ">
<div>
<input class="form-control " placeholder="Re-enter Password" id="confirm_password" name="confirm_password" type="password" />
</div>
</div>
<div class="form-group">
<div>
<button type="submit" id="btnRegister" class="btn btn-primary btn-lg btn-block">Submit</button>
</div>
</div>
</form>
</div>
JS:
// Submit registration form on button click last_name:{ required: true},
$('form#register_form').validate({
rules: {
first_name: {
required: true,
alpha: true
},
email_id: {
required: true,
email: true
},
phone_number: {
required: true,
number: true,
minlength: 8,
maxlength: 10
},
password: {
required: true,
minlength: 6
},
confirm_password: {
required: true,
minlength: 6,
equalTo: "#password"
},
},
messages: {
first_name: {
required: "Please enter First Name.",
alpha: "Special Characters not allowed."
},
email_id: {
required: "Please enter a email address.",
email: "Please enter a valid email address."
},
phone_number: {
required: "Please enter Phone Number." ,
number: "Please enter Numeric values for Phone Number."
},
password: {
required: "Please provide a password.",
minlength: "Your password must be at least 6 characters long."
},
confirm_password: {
required: "Please provide a password.",
minlength: "Your password must be at least 6 characters long.",
equalTo: "Please enter the same password as above."
},
},
submitHandler: function(form) {
var post_data = $("#register_form").serializeArray();
//var phoneExten = $("ul.country-list li.active").attr('data-dial-code');
var phoneExt = $("#phone_number").intlTelInput("getNumber");
post_data.push({name: "phone_number_with_ext", value: phoneExt});
//console.log(post_data);
$.ajax({
url: "/createAccount",
type: "POST",
data: post_data
}).done(function(res) {
//console.log(res);
var data = $.parseJSON(res);
if( data.success){
$('form#register_form div.form div.alert').removeClass('alert-danger').addClass('alert-success').text('User Created Successfully.').show().delay(2000).fadeOut('slow');
}else{
$('div.form div.alert').addClass('alert-danger').text(data.error_msg.message).show().delay(2000).fadeOut('slow');
$("div.form").scrollTop();
}
});
}
});
Added success message in javascript it is working fine for failure message but not working for success message and once data is submitting it is displaying the data still in form fields.Not getting the data cleared.

Following line work like: first it find from#register_form withing the elements it next find div.form (which isn't inside the form#register_form) then jquery try to find div.alert withing div.form which is not found in your current HTML structure.
div.form is parent node of form#register_form.
$('form#register_form div.form div.alert').removeClass('alert-danger').addClass('alert-success').text('User Created Successfully.').show().delay(2000).fadeOut('slow');
You should change it to:
$('div.alert').removeClass('alert-danger').addClass('alert-success').text('User Created Successfully.').show().delay(2000).fadeOut('slow');
As far as you're submitting form through AJAX you need to clear out all form fields using jquery. You can do it like.
$('form#register_form').trigger("reset");

After end of the code use this line to refresh the page:
redirect('Login/createAccount','refresh');
For Success message:
In Controller Code:
$this->session->set_flashdata('Add', 'Your da`ta added Successfully..');
redirect('Login/createAccount','refresh');
In View page after body:
<?php if($this->session->flashdata('Add')){ ?>
<center><div id="successMessage" class="alert bg-success alert-styled-left">
<button type="button" class="close" data-dismiss="alert"><span>×</span><span class="sr-only">Close</span></button>
<span class="text-semibold"><?php echo $this->session->flashdata('Add'); ?></span>
</div></center>
<?php } ?>
Javascript code for disable the flash data after particular time:
<script type="text/javascript">
$(document).ready(function(){
$("#successMessage").delay(5000).slideUp(300);
});
</script>

Related

Submitting a form without reloading the page

I have a form which works fine but after submitting it reloads the page. I want it to display the message under the form instead of reloading the page.
Here is my html code:
<form class=" form-horizontal" action="php/contact.php" method="post" id="contact_form" name="contact-form">
<fieldset>
<div class="form-group">
<input name="firstname" placeholder="First Name" class="form-control" type="text">
<input name="lastname" placeholder="Last Name" id="lastname" class="form-control" type="text">
<input name="email" placeholder="E-Mail Address" class="form-control" type="text">
<input type="text" name="mail"> <!-- anti spam - needs to stay non-filled - hidden by css -->
<input name="phone" placeholder="(+44) 020 1234 5678" class="form-control" type="text">
<input name="company" placeholder="Company name" class="form-control" type="text">
<input name="website" placeholder="Website or domain name" class="form-control" type="text">
<textarea class="form-control" name="message" placeholder="Your message"></textarea>
<!-- Success message -->
<div class="alert alert-success" role="alert" id="success_message">
Thanks for contacting us, we will get back to you shortly.</div>
<button type="submit" class="btn btn-block btn-primary">Send <span class="fa fa-fw fa-lg fa-send"></span> </button>
</div>
</fieldset>
</form>
I also use jquery validation scripts and this is a quick summary to this script ( I believe the most of changes need to be done here):
$(function() {
$("form[name='contact-form']").validate({
rules: {
firstname: "required",
message: "required",
email: {
required: true,
email: true
},
},
messages: {
firstname: " Please enter your firstname",
email: " Please enter a valid email address",
message: " Please type your message"
},
submitHandler: function(form) {
form.submit();
}
});
});
And this is a php code, which reloads the page after submitting:
<?php
$adresdo = "info#tucado.com";
$temat = "Message from tucado.com";
$zawartosc = "First Name: ".$_POST['firstname']."\n"
."Last Name: ".$_POST['lastname']."\n"
."Company: ".$_POST['company']."\n"
."Email: ".$_POST['email']."\n"
."Telephone: ".$_POST['phone']."\n"
."Website: ".$_POST['website']."\n"
."Message: ".$_POST['message']."\n";
if(!$_POST['firstname'] || !$_POST['email'] || !$_POST['message']){
header("Location: ../contact.html");
exit;
}
$email = $_POST['email'];
if(mail($adresdo, $temat, $zawartosc, 'From: Contact <'.$email.'>')){
header("Location: ../msg-sent.html");
}
?>
Could you please help me in modifying this code to display a message (id="success_message") when the message is sent? Thank you for your help.
Try ajax submission. put ajax code inside submit handler, use serialise or formdata to fetch the whole form .See example.
submitHandler: function(form) {
$.ajax({
url: "name_of_file.php",
type: "POST",
data: new FormData($(form)),
cache: false,
success: function(data) {
$("#success_message").html(data);
}
});
return false;
},
echo desired output in the php file so as to retreive it in data.

jQuery validation with codeigniter and ajax submission not working

I am use codeigniter framework to create a registration form I have also use jQuery to validate the fields the validation is working but after filling all details and click register button nothing is happen jQuery does not post data to controller. please help
Here is my html code:
<form method="post" action="" name="sentMessage" id="contactForm" novalidate >
<div class="row">
<div class="col-sm-12">
<h3>Registration Form</h3>
</div>
<div class="col-sm-12">
<div class="form-group">
<input class="text required" type="text" placeholder="UserName" name="username" id="uname" data-validation-required-message="Please enter your UserName." />
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required" type="text" placeholder="First Name" name="fname" id="fname" data-validation-required-message="Please enter your First Name."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required " type="text" placeholder="Last Name" name="lname" id="lname" data-validation-required-message="Please enter your Last Name."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required email" type="email" placeholder="Email" name="email" id="uemail" data-validation-required-message="Please enter your Email."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required" type="password" placeholder="Password" name="password" id="upassword" data-validation-required-message="Please enter your Password."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required" type="password" placeholder="Confirm Password" name="cpassword" id="cpassword" data-validation-required-message="Please enter your Password."/>
<p class="help-block text-danger"></p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 rst-contactsubmit">
<div class="form-group">
<!-- required data-validation-required-message="Please enter your message." -->
<p class="help-block text-danger"></p>
<div id="success"></div>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="REGISTER" />
</div>
</div>
</form>
My jquery code :
if( jQuery("#contactForm").length ) {
jQuery("#contactForm input").jqBootstrapValidation({
preventSubmit: true,
submitError: function(jQueryform, event, errors) {
// additional error messages or events
},
submitSuccess: function(jQueryform, event) {
event.preventDefault(); // prevent default submit behaviour
// get values from FORM
var username = jQuery("input#contact-username").val();
var fname = jQuery("input#contact-fname").val();
var lname = jQuery("input#contact-lname").val();
var email = jQuery("input#contact-email").val();
var password = jQuery("input#contact-password").val();
var firstName = fname; // For Success/Failure Message
// Check for white space in name for Success/Fail message
if (firstName.indexOf(' ') >= 0) {
firstName = fname.split(' ').slice(0, -1).join(' ');
}
jQuery.ajax({
type: "POST",
url: "<?php echo base_url()?>index.php/login/create_user",
data: {
username: username,
fname: fname,
lname: lname,
email: email,
password: password,
},
cache: false,
success: function() {
// Success message
jQuery('#success').html("<div class='alert alert-success'>");
jQuery('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
jQuery('#success > .alert-success')
.append("<strong>Your message has been sent. </strong>");
jQuery('#success > .alert-success')
.append('</div>');
//clear all fields
jQuery('#contactForm').trigger("reset");
},
error: function() {
// Fail message
jQuery('#success').html("<div class='alert alert-danger'>");
jQuery('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
jQuery('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that server is not responding. Please try again later!");
jQuery('#success > .alert-danger').append('</div>');
//clear all fields
jQuery('#contactForm').trigger("reset");
},
})
},
filter: function() {
return jQuery(this).is(":visible");
}
});
}
And my controller code :
<?php
class Login extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function index(){
$this->load->helper(array('form'));
$this->load->view('login');
}
function validate_credentials(){
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query){
$data = array('username' => $this->input->post('username'), 'is_logged_in' => true);
$this->session->set_userdata($data);
redirect('<?php base_url()index.php/user_dashboard');
}
}
function create_user(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'trim|required|callback_check_username');
$this->form_validation->set_rules('fname', 'Name', 'trim|required');
$this->form_validation->set_rules('lname', 'Last Name', 'trim|required');
$this->form_validation->set_rules('email', 'Email-id', 'trim|required|valid_email|callback_check_email');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]');
$this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required|matches[password]');
if($this->form_validation->run() == FALSE){
echo "fail";
}
else{
$this->load->model('membership_model');
if($query = $this->membership_model->create_user())
{
$data['account created'] = 'your account is created';
$this->load->view('login', $data);
}
else{
$this->load->view('register');
}
}
}
function check_username($requested_username){
$this->load->model('membership_model');
$username_available = $this->membership_model->check_username($requested_username);
if($username_available){
return TRUE;
}
else{
return FALSE;
}
}
function check_email($requested_email){
$this->load->model('membership_model');
$email_available = $this->membership_model->check_email($requested_email);
if($email_available){
return TRUE;
}
else{
return FLASE;
}
}
}
?>
The problem seems to be in the jQuery code
url: "<?php echo base_url()?>index.php/login/create_user",
jQuery doesn't read PHP code. try changing it to
url: "login/create_user",
Hope this helps.
Codeigniter Validation will not work with Jquery/Ajax Form Submission. Please manually do the validation...
foreach($_POST as $key =>$value){
if($value==''){
echo 'Error';
}
}
By this server response you can alert the user Or else simply
https://jqueryvalidation.org/documentation/ use this client side validation.

Contact form working partially

i need some help with this contact form im trying to fix.
The thing is that it works... kinda. i do get the messages but no success confirmation. the form just fades out a lil' bit and get's stuck i guess but the message does go through.
Any ideas of what im missing here?
<form action="#" id="contact-form">
<div class="input-group name-email">
<div class="input-field">
<input type="text" name="name" id="name" placeholder="Naam/Bedrijf" class="form-control">
</div>
<div class="input-field">
<input type="email" name="email" id="email" placeholder="Email" class="form-control">
</div>
<div class="input-field">
<input type="phone" name="phone" id="phone" placeholder="Telefoon" class="form-control">
</div>
</div>
<div class="input-group">
<textarea name="message" id="message" placeholder="Bericht" class="form-control"></textarea>
</div>
<div class="input-group">
<input type="submit" id="form-submit" class="pull-right" value="Verzenden ">
</div>
</form>
that is my form script
$('#contact-form').validate({
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: true,
email: true
},
message: {
required: true
}
},
messages: {
name: {
required: "name",
minlength: 2
},
email: {
required: "no email"
},
message: {
required: "no msg",
minlength: 2
}
},
submitHandler: function(form) {
$(form).ajaxSubmit({
type: "POST",
data: $(form).serialize(),
url: "process.php",
success: function() {
$('#contact-form :input').attr('disabled', 'disabled');
$('#contact-form').fadeTo("slow", 0.15, function() {
$(this).find(':input').attr('disabled', 'disabled');
$(this).find('label').css('cursor', 'default');
$('#success').fadeIn();
});
},
error: function() {
$('#contact-form').fadeTo("slow", 0.15, function() {
$('#error').fadeIn();
});
}
});
}
});
});
</script>
validation
<?php
$to = "";
$from = $_REQUEST['name'];
$subject = $_REQUEST['subject'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"subject"} = "subject";
$fields{"message"} = "message";
$body = "Here is what was sent:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$send = mail($to, $subject, $body, $headers);?>
and finally my process.php script. any help would be appreciated. thanks.
<div id="success">
<span>
<p>Your message was sent successfully! I will be in touch as soon as I can.</p>
</span>
</div>
<div id="error">
<span>
<p>Something went wrong, try refreshing and submitting the form again.</p>
</span>
</div>
I have this piece of code as well at the end in the HTML but it just prints with or without submitting

return some data from model or controller to submithandler on jquery validation

I have a form in a modal bootstrap looked like this :
<?php
$properties = array('class' => 'form-horizontal', 'id' => 'formpassword');
echo form_open("control_member/updatePassword", $properties);
?>
<div class="modal hide fade" id="myModalChangePassword">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h2 id="mainTitle" style="color: black; text-shadow: none;">Silahkan ganti Password Anda: </h2>
</div>
<div class="modal-body">
<fieldset>
<div class="input-prepend" title="Password">
<span class="add-on"><i class="halflings-icon lock"></i></span>
<input class="input-xlarge" name="password_lama" id="old_password" type="password" placeholder="Current password" autofocus>
</div>
<div class="input-prepend" title="Password Baru">
<span class="add-on"><i class="halflings-icon lock"></i></span>
<input class="input-xlarge" name="password_baru" id="new_password" type="password" placeholder="New Password"/>
</div>
<div class="input-prepend" title="Confirm Password">
<span class="add-on"><i class="halflings-icon lock"></i></span>
<input class="input-xlarge" name="password_confirm" id="confirm_password" type="password" placeholder="Confirm Password"/>
</div>
<div>
<button class="btn btn-primary" id="btn-save-password">Save</button>
<button class="btn" data-dismiss="modal">Cancel</button>
</div>
<div class="clearfix"></div>
</fieldset>
</div>
</div>
<?php echo form_close(); ?>
This is the controller to handling the data from code above :
public function updatePassword() {
$new = $this->input->post('new_password');
$user_id = $this->session->userdata('id_user');
$row = $this->model_user->update_password($user_id, $new);
$affected_rows = $this->db->affected_rows();
if ($affected_rows > 0) {
//echo json_encode($row); just test, the browser return true
return json_encode($row);
} else {
return "No updates";
}
}
And now, I use jquery validation to verifiying the data from code above like this :
$(document).ready(function() {
$("#formpassword").validate({
rules: {
old_password : {
required: true,
},
new_password : {
required: true,
},
confirm_password : {
equalTo: "#new_password"
}
},
messages: {
old_password : "Password lama anda salah",
new_password : "Password baru tidak cocok",
confirm_password : "Tidak cocok"
},
submitHandler: function(form) {
alert("Working"); // Not success
$.blockUI({message: '<h1><img src="http://localhost/tresnamuda/assets/img/loader.gif" />Sedang diproses</h1>'});
$.ajax({
method: "POST",
url: form.action,
data: form.serialize()
})
.done(function(msg) {
$.blockUI({message: "Data Submited "});
});
}
});
My goal is, how can I make when the user is success, the modal bootstrap just closed, and the data is succesfull to update ? Coz, in my case, it's redirect to controller updatePassword. So, I expected, when SUbmit is success, it still gives me a same page.

Contact form not submitting using Ajax and PHP

I'm building a contact form for my site using jQuery validation plugin, ajax call to forward the data to the PHP file, and finally sending the email. Seems like the data is not passed to the php mailer. I'm new to server side technologies, I read a lot but still can't make this working, so please advise me.
the form:
<form class="form-horizontal" role="form" id="contactForm" name="contactForm" method="post">
<div class="form-group">
<label class="col-lg-2 control-label" for="inputName">Name</label>
<div class="col-lg-10">
<input class="form-control" id="inputName" name="inputName" placeholder="Your name" type="text" value="" required>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputEmail">Email</label>
<div class="col-lg-10">
<input class="form-control" id="inputEmail" name="email" placeholder="your#email.com" type="email" value="" required>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputMessage">Message</label>
<div class="col-lg-10">
<textarea class="form-control" id="inputMessage" name="inputMessage" placeholder="Message" rows="3" required></textarea>
<button class="btn btn-success pull-right" type="submit" name="submit" id="submit">Send</button>
</div>
</div>
the javascript:
/*validate contact form */
$(function() {
$('#contactForm').validate({
rules: {
inputName: {
required: true,
minlength: 2
},
inputEmail: {
required: true,
email: true
},
inputMessage: {
required: true
}
},
messages: {
name: {
required: "name required",
minlength: "name must be at least 2 characters"
},
email: {
required: "email required"
},
message: {
required: "message required",
minlength: 10
}
},
submitHandler: function(form) {
$('form').ajaxSubmit({
type:"POST",
data: $(form).serialize(),
url:"index2.php",
success: function() {
alert("message sent");
},
error: function() {
alert("due to an error msg wasnt sent");
}
});
}
});
});
php file:
<?php
if ($_POST["submit"]) {
$name = trim($_POST['inputName']);
$email = trim($_POST['inputEmail']);
$message = $_POST['inputMessage'];
$from = 'Demo Contact Form';
$to = 'example#example.com';
$subject = 'Message from Contact Demo ';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
mail($to, $subject, $body, $from);
}
?>
$(form).serialize() doesn't include the submit field (how would it know which submit button you clicked on?), so if ($_POST['submit']) will never succeed. Use:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
instead.
Or, if this script is only used for AJAX calls, and not loaded directly by the browser, you can omit that check entirely, as in Glizzweb's answer.
better use checking if:
if (isset($_POST['inputName'])){
//rest part here
}
// and see if the file is in same directory otherwise give relative path.
use this to send form content:
submitHandler: function() {
$('form').ajaxSubmit({
type:"POST",
data: $('#contactForm').serialize(),
url:"submit.php",
success: function() {
alert("message sent");
},
error: function() {
alert("due to an error msg wasnt sent");
}
});
}
In your ajax.php remove $_POST["submit"]
<?php
$name = trim($_POST['inputName']);
$email = trim($_POST['inputEmail']);
$message = $_POST['inputMessage'];
$from = 'Demo Contact Form';
$to = 'example#example.com';
$subject = 'Message from Contact Demo ';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
mail($to, $subject, $body, $from);
?>
In ajax page $_POST['submit'] need remove because you post values using "$(form).serialize()" and In you not post value to ajax page. remove if condition "if ($_POST["submit"]) {}" and change like this "if (!empty($_POST["inputName"])) { }"
$name = trim($_POST['inputName']);
$email = trim($_POST['inputEmail']);
.....
....
....
Try this code:
<html>
<head>
<script src="js/jquery-1.11.0.js" type="text/javascript"></script>
<script src="js/jquery.validate.min.js" type="text/javascript"></script>
<script src="js/additional-methods.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$('#contactForm').submit(function(e){
e.preventDefault();
$('#contactForm').validate({
rules: {
inputName: {
required: true,
minlength: 2
},
inputEmail: {
required: true,
email: true
},
inputMessage: {
required: true
}
},
messages: {
name: {
required: "name value required",
minlength: "name must be at least 2 characters"
},
email: {
required: "email is required"
},
message: {
required: "message is required",
minlength: 10
}
},
submitHandler: function(form) {
alert($('form').html());
$.ajax({
type:"POST",
data: $(form).serialize(),
url:"test1.php",
success: function() {
alert("message sent");
},
error: function() {
alert("due to an error msg wasnt sent");
}
});
}
});
});
});
</script>
</head>
<body>
<form class="form-horizontal" role="form" id="contactForm" name="contactForm" method="post">
<div class="form-group">
<label class="col-lg-2 control-label" for="inputName">Name</label>
<div class="col-lg-10">
<input class="form-control" id="inputName" name="inputName" placeholder="Your name" type="text" value="" >
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputEmail">Email</label>
<div class="col-lg-10">
<input class="form-control" id="inputEmail" name="email" placeholder="your#email.com" type="email" value="" >
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputMessage">Message</label>
<div class="col-lg-10">
<textarea class="form-control" id="inputMessage" name="inputMessage" placeholder="Message" rows="3" ></textarea>
<input class="btn btn-success pull-right" type="submit" name="submit" id="submit" value="Send">
</div>
</div>
</body>
</html>
It is working and showing message sent and ajax call also made. you are doing some mistakes while performing ajax call. as jquery validation plugin does not provide any ajaxsubmit function instead use jquery ajax function as i have used. try it and let me know for further issue.
Change this code to fit your requirement.

Categories