It does not validate before AJAX call to send information to DB. How can i activate the Validation first?
$(document).ready(function() {
$("#signup").validationEngine('attach', {
promptPosition : "centerRight",
scroll : false,
ajaxFormValidation: true,
onBeforeAjaxFormValidation: beforeCall,
onAjaxFormComplete: ajaxValidationCallback,
});
});
$("#submit").click(function() {
var url = "insertintoDB.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#signupform").serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the php script.
}
});
return false; // avoid to execute the actual submit of the form.
});
It does direct to insertintoDB.php but does not validate the following form.
<form class="form-horizontal" id="signup" name="signup" method="post" action="insertDB.php">
<div class="control-group">
<label class="control-label" for="inputSurname">Name</label>
<div class="controls"><input type="text" id="inputSurname" name="inputSurname" placeholder="Surname" class="validate[required]" /></div>
</div>
<button type="submit" id="submit" class="btn btn-success">Sign Up!</button>
</form>
How can I make it validate first before passing into the PHP for data insertion?