Validation plugin - insert into MySQL
Hi everybody,
I'm trying to insert form data into MySQL database after validation. I understand that I need to pass the data to server-side script, like this one:
- $(document).ready(function(){
- $("form#submit").submit(function() {
- // we want to store the values from the form input box, then send via ajax below
- var fname = $('#fname').attr('value');
- var lname = $('#lname').attr('value');
- $.ajax({
- type: "POST",
- url: "ajax.php",
- data: "fname="+ fname +"& lname="+ lname,
- success: function(){
- $('form#submit').hide(function(){$('div.success').fadeIn();});
- }
- });
- return false;
- });
- });
But, I don't get it, where should I put code like this? Validation function looks like this:
- $().ready(function() {
- // validate the comment form when it is submitted
- $("#commentForm").validate();
-
- // validate signu
- $("#signupForm").validate({
- rules: {
- firstname: "required",
- lastname: "required",
- },
- messages: {
- firstname: "Please enter your firstname",
- lastname: "Please enter your lastname",
- }
- });
Thanks