jquery验证提交按钮不起作用

时间:2012-12-22 01:20:37

标签: php javascript jquery

我有一个验证必填字段的代码,当有一个没有值的字段时验证工作。我的问题是,当我完全填满所有字段时,代码不提交我的表单,它只返回到输入值的表单。

这是我的代码:

<script type="text/javascript" language="javascript">

    $(document).ready(function () {

        var rules = {
            vsi: {
                required: true,
                minlength: 7
            },
            date: "required",
            csname: "required",
            color: "required"
        };
        var messages = {
            vsi: {
                required: "VSI Number must be Inputted.",
                minlength: "VSI Number should be atleast 7 numbers."
            },
            date: "Date is requried",
            csname: "Customer Name is required",
             color: "Color is required"
        };


        var validator
            = new jQueryValidatorWrapper("FormToValidate",
                rules, messages);


        $("#Save").click(function ()
         {
            if (!validator.validate())

                return;
              alert("Data Saved!");

        });
    });

</script>

任何人都可以修改我的代码吗?谢谢!

这是我的index.php

<?php 


    require("common.php"); 


    if(empty($_SESSION['user'])) 
    { 

        header("Location: login.php?attempt=1"); 

    } 


?> 
<?php
include ('connection.php');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" href="css/1.css" type="text/css" media="screen,projection" />
    <link href="Styles/ui-lightness/jquery-ui-1.8.13.custom.css"
        rel="stylesheet" type="text/css" />
    <link href="Styles/Site.css" rel="stylesheet" type="text/css" />

    <script src="Scripts/jquery-1.6.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery.validate.wrapper.js" type="text/javascript"></script>

<script type="text/javascript" language="javascript">

    $(document).ready(function () {
        // 1. prepare the validation rules and messages.
        var rules = {
            vsi: {
                required: true,
                minlength: 7
            },
            date: "required",
            csname: "required",
            color: "required"
        };
        var messages = {
            vsi: {
                required: "VSI Number must be Inputted.",
                minlength: "VSI Number should be atleast 7 numbers."
            },
            date: "Date is requried",
            csname: "Customer Name is required",
             color: "Color is required"
        };

        // 2. Initiate the validator
        var validator
            = new jQueryValidatorWrapper("FormToValidate",
                rules, messages);

        // 3. Set the click event to do the validation
        $("#Save").click(function ()
                     {
                        if (!validator.validate())
                           {
                             return;
                            }
                        $('#FormToValidate').submit();
                         alert("Data Saved!");
                          return;

                    });
    });

</script>
</head>

<body>



<div id="wrapper">
<div id="innerwrapper">

        <div id="header">
          <ul id="nav">  
          <center><h3><font color="#FFFFFF">Vehicle Sales Transaction Form - UNIT VEHICLE SALES</font></h3></center> 
          </ul>
</div>

</div>
</div>
<br />

<div id="container">

<form action="index2.php" method="POST" >
  <a href="form_menu.php" class="small button blue">MAIN MENU</a>
  <a href="index.php" class="small button blue">EDIT</a>
  <a href="logout.php" class="small button blue">EXIT</a>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input name="vsisearch" type="text" style="padding-bottom:5px" />&nbsp;&nbsp;&nbsp;<input class="small button blue" name="Search" type="submit" id="Search" value="Search" /></form></div>
 <br/>
     <br/>
<div id="container">
    <div id="primary">
      <p>CUSTOMER NAME:</p>
        <p>VEHICLE UNIT:</p>
      <p>COLOR:</p>
        <p>CONDUCTION STICKER:</p>
        <p>MKTG. PROFESSIONAL:</p>
        <p>GROUP SALES MANAGER:</p>
        <p>TYPE OF TRANSACTION:</p>
      <p>DOWN PAYMENT:</p>
        <p>AMOUNT FINANCED:</p>
        <p>DI RATE:</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>
          <label>PREVIOUS <br />
          </label>
        </p>
</div>
<form id="FormToValidate" action="insert.php" method="POST">
  <div id="content">
    <p>
      <input type="text" name="csname" id="csname" style="width:250px" margin-bottom="3px"/>
         </p>
        <p>
          <select name="units" style="width:254px">
            <option value="AVANZA 1.3J M/T">AVANZA 1.3J M/T</option>
            <option value="AVANZA 1.3E A/T">AVANZA 1.3E A/T</option>
            <option value="AVANZA 1.3E M/T">AVANZA 1.3E M/T</option>
            <option value="AVANZA 1.5G M/T">AVANZA 1.5G M/T</option>
            <option value="AVANZA 1.5G A/T">AVANZA 1.5G A/T</option>
            <option value="86 2.0L A/T ">86 2.0L A/T </option>
            <option value="86 2.0L A/T (White Pearl)">86 2.0L A/T (White Pearl)</option>
            <option value="86 2.0L A/T Aero">86 2.0L A/T Aero</option>
            <option value="86 2.0L A/T Aero (White Pearl)">86 2.0L A/T Aero (White Pearl)</option>
            <option value="86 2.0L M/T ">86 2.0L M/T </option>
            <option value="86 2.0L M/T (White Pearl)">86 2.0L M/T (White Pearl)</option>
            <option value="CAMRY 3.5Q (White Pearl)">CAMRY 3.5Q (White Pearl)4</option>
            <option value="CAMRY 3.5Q">CAMRY 3.5Q</option>
            <option value="CAMRY 2.5V ">CAMRY 2.5V </option>
            <option value="CAMRY 2.5G (White Pearl)">CAMRY 2.5G (White Pearl)</option>
            <option value="CAMRY 2.5G ">CAMRY 2.5G </option>
            <option value="PRIUS C ">PRIUS C </option>
            <option value="PRIUS C (White Pearl)">PRIUS C (White Pearl)</option>
            <option value="PRIUS C Full Option">PRIUS C Full Option</option>
            <option value="PRIUS C Full Option (White Pearl)">PRIUS C Full Option (White Pearl)</option>
            <option value="COROLLA 2.0V AT (white pearl)">COROLLA 2.0V AT (white pearl)</option>
            <option value="COROLLA 2.0V AT">COROLLA 2.0V AT</option>
            <option value="COROLLA 1.6V AT (white pearl)">COROLLA 1.6V AT (white pearl)</option>
            <option value="COROLLA 1.6V AT">COROLLA 1.6V AT</option>
            <option value="COROLLA 1.6G AT">COROLLA 1.6G AT</option>
            <option value="COROLLA 1.6G MT">COROLLA 1.6G MT</option>
            <option value="COROLLA 1.6E MT">COROLLA 1.6E MT</option>
            <option value="FORTUNER 4X4V DSL AT">FORTUNER 4X4V DSL AT</option>
            <option value="FORTUNER 4X4V DSL AT (white pearl)">FORTUNER 4X4V DSL AT (white pearl)</option>
            <option value="FORTUNER 4X2G DSL AT">FORTUNER 4X2G DSL AT</option>
            <option value="FORTUNER 4X2G DSL AT (white pearl)">FORTUNER 4X2G DSL AT (white pearl)</option>
            <option value="FORTUNER 4X2G DSL MT">FORTUNER 4X2G DSL MT</option>
            <option value="FORTUNER 4X2G DSL MT (white pearl)">FORTUNER 4X2G DSL MT (white pearl)</option>
            <option value="FORTUNER 4X2G GAS AT">FORTUNER 4X2G GAS AT</option>
            <option value="FORTUNER 4X2G GAS AT (white pearl)">FORTUNER 4X2G GAS AT (white pearl)</option>
            <option value="FORTUNER 4X4V DSL AT">FORTUNER 4X4V DSL AT</option>
            <option value="FORTUNER 4X2G DSL AT">FORTUNER 4X2G DSL AT</option>
            <option value="FORTUNER 4X2G DSL MT">FORTUNER 4X2G DSL MT</option>
            <option value="FORTUNER 4X2G GAS AT">FORTUNER 4X2G GAS AT</option>
            <option value="HIACE COMMUTER">HIACE COMMUTER</option>
            <option value="HIACE COMMUTER (WHITE)">HIACE COMMUTER (WHITE)</option>
            <option value="HIACE GL GRANDIA 1T">HIACE GL GRANDIA 1T</option>
            <option value="HIACE GL GRANDIA 2T">HIACE GL GRANDIA 2T</option>
            <option value="HIACE S GRANDIA LEATHER MONOTONE">HIACE S GRANDIA LEATHER MONOTONE</option>
            <option value="HIACE S GRANDIA LEATHER 2-TONE">HIACE S GRANDIA LEATHER 2-TONE</option>
            <option value="HIACE S GRANDIA FABRIC MONOTONE">HIACE S GRANDIA FABRIC MONOTONE</option>
            <option value="HIACE S GRANDIA FABRIC 2-TONE">HIACE S GRANDIA FABRIC 2-TONE</option>
            <option value="HIACE COMMUTER">HIACE COMMUTER</option>
            <option value="HIACE COMMUTER (WHITE)">HIACE COMMUTER (WHITE)</option>
            <option value="HIACE GL GRANDIA 1T">HIACE GL GRANDIA 1T</option>
            <option value="HIACE GL GRANDIA 2T">HIACE GL GRANDIA 2T</option>
            <option value="HIACE S GRANDIA LEATHER MONOTONE">HIACE S GRANDIA LEATHER MONOTONE</option>
            <option value="HIACE S GRANDIA LEATHER 2-TONE">HIACE S GRANDIA LEATHER 2-TONE</option>
            <option value="HIACE S GRANDIA FABRIC MONOTONE">HIACE S GRANDIA FABRIC MONOTONE</option>
            <option value="HIACE S GRANDIA FABRIC 2-TONE">HIACE S GRANDIA FABRIC 2-TONE</option>
            <option value="HILUX 3.0L G 4X4 AT">HILUX 3.0L G 4X4 AT</option>
            <option value="HILUX 3.0L G 4X4 MT">HILUX 3.0L G 4X4 MT</option>
            <option value="HILUX 2.5L G 4X2 MT">HILUX 2.5L G 4X2 MT</option>
            <option value="HILUX 2.5L E 4X2 MT">HILUX 2.5L E 4X2 MT</option>
            <option value="HILUX 2.5L J 4X2 MT">HILUX 2.5L J 4X2 MT</option>
            <option value="HILUX FX W/AC">HILUX FX W/AC</option>
            <option value="HILUX FX W/O AC">HILUX FX W/O AC</option>
            <option value="HILUX CAB AND CHASSIS">HILUX CAB AND CHASSIS</option>
            <option value="HILUX 4x4G AT">HILUX 4x4G AT</option>
            <option value="HILUX 4x4G MT">HILUX 4x4G MT</option>
            <option value="HILUX 4x2G MT">HILUX 4x2G MT</option>
            <option value="HILUX 4x2E MT">HILUX 4x2E MT</option>
            <option value="HILUX 4x2J MT">HILUX 4x2J MT</option>
            <option value="HILUX FX w/rear AC">HILUX FX w/rear AC</option>
            <option value="HILUX FX w/o rear AC">HILUX FX w/o rear AC</option>
            <option value="HILUX Cab &amp; Chassis">HILUX Cab &amp; Chassis</option>
            <option value="INNOVA 2.5G DSL MT">INNOVA 2.5G DSL MT</option>
            <option value="INNOVA 2.5G DSL AT">INNOVA 2.5G DSL AT</option>
            <option value="INNOVA 2.5V DSL AT">INNOVA 2.5V DSL AT</option>
            <option value="INNOVA 2.5J DSL MT">INNOVA 2.5J DSL MT</option>
            <option value="INNOVA 2.5E DSL MT">INNOVA 2.5E DSL MT</option>
            <option value="INNOVA 2.5E DSL AT">INNOVA 2.5E DSL AT</option>
            <option value="INNOVA 2.5G DSL MT (White Pearl)">INNOVA 2.5G DSL MT (White Pearl)</option>
            <option value="INNOVA 2.5G DSL AT (White Pearl)">INNOVA 2.5G DSL AT (White Pearl)</option>
            <option value="INNOVA 2.5V DSL AT (White Pearl)">INNOVA 2.5V DSL AT (White Pearl)</option>
            <option value="INNOVA 2.0G GAS MT">INNOVA 2.0G GAS MT</option>
            <option value="INNOVA 2.0G GAS AT">INNOVA 2.0G GAS AT</option>
            <option value="INNOVA 2.0V GAS AT">INNOVA 2.0V GAS AT</option>
            <option value="INNOVA 2.0J GAS MT">INNOVA 2.0J GAS MT</option>
            <option value="INNOVA 2.0E GAS MT">INNOVA 2.0E GAS MT</option>
            <option value="INNOVA 2.0E GAS AT">INNOVA 2.0E GAS AT</option>
            <option value="INNOVA 2.0G GAS MT (White Pearl)">INNOVA 2.0G GAS MT (White Pearl)</option>
            <option value="NNOVA 2.0G GAS AT (White Pearl)">NNOVA 2.0G GAS AT (White Pearl)</option>
            <option value="INNOVA 2.0V GAS AT (White Pearl)">INNOVA 2.0V GAS AT (White Pearl)</option>
            <option value="LC PRADO AT GAS">LC PRADO AT GAS</option>
            <option value="LC PRADO AT GAS (white pearl)">LC PRADO AT GAS (white pearl)</option>
            <option value="LC PRADO AT">LC PRADO AT</option>
            <option value="LC PRADO AT (white pearl)">LC PRADO AT (white pearl)</option>
            <option value="LC PRADO MT">LC PRADO MT</option>
            <option value="LC PRADO MT (white pearl)">LC PRADO MT (white pearl)</option>
            <option value="LAND CRUISER 200">LAND CRUISER 200</option>
            <option value="LAND CRUISER 200 (White Pearl)">LAND CRUISER 200 (White Pearl)</option>
            <option value="LAND CRUISER 200 Full Option">LAND CRUISER 200 Full Option</option>
            <option value="LAND CRUISER 200 Full Option (White Pearl)">LAND CRUISER 200 Full Option (White Pearl)</option>
            <option value="PREVIA 2.4L FULL A/T (MC)">PREVIA 2.4L FULL A/T (MC)</option>
            <option value="PREVIA 2.4L FULL A/T (MC white pearl)">PREVIA 2.4L FULL A/T (MC white pearl)</option>
            <option value="PREVIA 2.4L STD A/T (MC)">PREVIA 2.4L STD A/T (MC)</option>
            <option value="PREVIA 2.4L STD A/T (MC white pearl)">PREVIA 2.4L STD A/T (MC white pearl)</option>
            <option value="RAV4 4X4 A/T (MC)">RAV4 4X4 A/T (MC)</option>
            <option value="RAV4 4X4 A/T (White Pearl) (MC)">RAV4 4X4 A/T (White Pearl) (MC)</option>
            <option value="RAV4 4X2 A/T (MC)">RAV4 4X2 A/T (MC)</option>
            <option value="RAV4 4X2 A/T (White Pearl) (MC)">RAV4 4X2 A/T (White Pearl) (MC)</option>
            <option value="VIOS 1.3E AT">VIOS 1.3E AT</option>
            <option value="VIOS 1.3E MT">VIOS 1.3E MT</option>
            <option value="VIOS 1.3J MT (IMP)">VIOS 1.3J MT (IMP)</option>
            <option value="VIOS 1.3J MT (OLD)">VIOS 1.3J MT (OLD)</option>
            <option value="VIOS 1.3 BASE MT">VIOS 1.3 BASE MT</option>
            <option value="VIOS 1.5 TRD A/T (white pearl)">VIOS 1.5 TRD A/T (white pearl)</option>
            <option value="VIOS 1.5 TRD A/T">VIOS 1.5 TRD A/T</option>
            <option value="VIOS 1.3G AT (OLD)">VIOS 1.3G AT (OLD)</option>
            <option value="VIOS 1.5SE A/T WHITE">VIOS 1.5SE A/T WHITE</option>
            <option value="VIOS 1.5SE A/T">VIOS 1.5SE A/T</option>
            <option value="VIOS 1.5G AT">VIOS 1.5G AT</option>
            <option value="VIOS 1.5G MT">VIOS 1.5G MT</option>
            <option value="MC VIOS 1.3E AT">MC VIOS 1.3E AT</option>
            <option value="MC VIOS 1.3E MT">MC VIOS 1.3E MT</option>
            <option value="MC VIOS 1.3J MT">MC VIOS 1.3J MT</option>
            <option value="MC VIOS 1.5G MT">MC VIOS 1.5G MT</option>
            <option value="MC VIOS 1.5G AT">MC VIOS 1.5G AT</option>
            <option value="MC VIOS 1.3G AT">MC VIOS 1.3G AT</option>
            <option value="MC VIOS 1.3 BASE MT">MC VIOS 1.3 BASE MT</option>
            <option value="MC VIOS 1.5SE AT">MC VIOS 1.5SE AT</option>
            <option value="MC VIOS 1.5SE AT (White Pearl)">MC VIOS 1.5SE AT (White Pearl)</option>
            <option value="YARIS 1.5 G A/T">YARIS 1.5 G A/T</option>
            <option value="YARIS 1.5 G M/T">YARIS 1.5 G M/T</option>
            <option value="TOYOTA PRIUS 1.8L Hybrid ">TOYOTA PRIUS 1.8L Hybrid </option>
            <option value="TOYOTA PRIUS 1.8L Hybrid (White Pearl)">TOYOTA PRIUS 1.8L Hybrid (White Pearl)</option>
            <option value="ALPHARD 2.4L White Pearl">ALPHARD 2.4L White Pearl</option>
            <option value="ALPHARD 2.4L">ALPHARD 2.4L</option>
            <option value="ALPHARD 3.5L White Pearl">ALPHARD 3.5L White Pearl</option>
            <option value="ALPHARD 3.5L">ALPHARD 3.5L</option>
            <option value="COASTER 30-SEAT Dsl M/T">COASTER 30-SEAT Dsl M/T</option>
          </select>
        </p>
        <p>
          <input type="text" name="color" id="color" style="width:250px"/>
        </p>


      <p>
        <input type="text" name="consticker" id="consticker" style="width:250px"/>
      </p>
      <p>
        <select name="mp" style="width:254px">
          <option value="AMATORIO, JESSAMYN ">AMATORIO, JESSAMYN </option>
          <option value="ANDAYA, JEDDELIA PEREZ ">ANDAYA, JEDDELIA PEREZ </option>
          <option value="BONDAD, KARYL ANN BARIAS">BONDAD, KARYL ANN BARIAS</option>
          <option value="BRIÑAS, NINA RICCI ROSE ESTIVA">BRIÑAS, NINA RICCI ROSE ESTIVA</option>
          <option value="BUSOG, MELANIE">BUSOG, MELANIE</option>
          <option value="CORNISTA, JOHN KARL CRISOSTOMO">CORNISTA, JOHN KARL CRISOSTOMO</option>
          <option value="EDAD, OLGA DESAMERO">EDAD, OLGA DESAMERO </option>
          <option value="ENDOZO, LORIE JANE SANCHEZ ">ENDOZO, LORIE JANE SANCHEZ </option>
          <option value="ESTIVA, ROYDAN BAYLON">ESTIVA, ROYDAN BAYLON </option>
          <option value="GAMARO, HONEYLET">GAMARO, HONEYLET</option>
          <option value="GONZALEZ, MADONA">GONZALEZ, MADONA</option>
          <option value="GUTIERREZ, DARA ANGELA">GUTIERREZ, DARA ANGELA </option>
          <option value="HERRERA, JAYSON">HERRERA, JAYSON </option>
          <option value="ILAGAN, FELIX DE LEON">ILAGAN, FELIX DE LEON </option>
          <option value="KATIGBAK, ARTHUR MOISES">KATIGBAK, ARTHUR MOISES</option>
          <option value="MANALILI, JASON  ">MANALILI, JASON </option>
          <option value="MARASIGAN, MICHAEL">MARASIGAN, MICHAEL </option>
          <option value="PAGCALIWAGAN, HOLLY ANN">PAGCALIWAGAN, HOLLY ANN </option>
          <option value="PANGANIBAN, TRISTAN">PANGANIBAN, TRISTAN </option>
          <option value="RAMIREZ, GERARD WEDINGCO">RAMIREZ, GERARD WEDINGCO </option>
          <option value="RAMOS, GIAN FRANCIS BRION">RAMOS, GIAN FRANCIS BRION </option>
          <option value="RAZON, NOEL">RAZON, NOEL </option>
          <option value="SALAZAR, ROBIN CARPIO">SALAZAR, ROBIN CARPIO </option>
          <option value="SOMBILLA, CELESTE MARLYNL">SOMBILLA, CELESTE MARLYN </option>
          <option value="TABABA, ROCRIS SANTHER DALE">TABABA, ROCRIS SANTHER DALE </option>
          <option value="VALENCIA, CAROL GARCIA">VALENCIA, CAROL GARCIA </option>
        </select>
      </p>
        <p>
          <select name="grm" style="width:254px">
            <option value="JOAN T. DE LUNA">JOAN T. DE LUNA</option>
            <option value="REAGER G. CARLOS">REAGER G. CARLOS</option>
            <option value="KARYL ANN B. BONDAD">KARYL ANN B. BONDAN</option>
            <option value="ALEX E. NEBRES">ALEX E. NEBRES</option>
          </select>
        </p>
        <p><select name="typeoftransact" style="width:254px">
<option value="CASH">CASH</option>
<option value="BANK FINANCING">BANK FINANCING</option>
<option value="BANK P.O.">BANK P.O.</option>
<option value="CORPORATE P.O.">CORPORATE P.O.</option>
<option value="GOVERNMENT P.O.">GOVERNMENT P.O.</option>
</select></p>
      <p>
        <input name="dp" type="dp" style="width:250px" />
      </p>
      <p>
        <input name="amount" type="amount" style="width:250px" />
      </p>
      <p>
        <input name="dirate" type="dirate" style="width:250px" />
      </p>
      <p>&nbsp;</p>
    <p>&nbsp;</p>
      <p align="right">AMNT PAID: </p>
<p>&nbsp;</p>
<p>NEXT</p>
<p>&nbsp;</p>
    <p>&nbsp;</p>
</div>

    <div id="secondary">
      <p>VSI No.:</p>
        <p>DATE:</p>
        <p>&nbsp; </p>
      <p>TYPE OF SUBSIDY 1:</p>
        <p>TYPE OF SUBSIDY 2:</p>
        <p>TYPE OF SUBSIDY 3:</p>
        <p>TYPE OF SUBSIDY 4:</p>
        <p>TYPE OF SUBSIDY 5:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
        <p>CHATTEL MORTGAGE:</p>
        <p>&nbsp;</p>
        <p>
          <input name="chapaid" type="text" style="width:120px" />
        </p>
<p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      <p>&nbsp;</p>
        <p>&nbsp;</p>
<p>&nbsp;</p>
        <p>&nbsp;</p>
</div>
    <div id="third">
      <p>
        <input type="text" name="vsi" id="vsi" style="width:180px"/>
</p>
<p>
  <input type="text" name="date" id="date" style="width:180px"/>
</p>
<p>&nbsp;</p>
<p>
  <select name="type1" style="width:180px">
    <option value="AVANZA 1.3J M/T">subd nov. promo</option>
    <option value="AVANZA 1.3E A/T">subd dec. promo</option>
    <option value="AVANZA 1.3E M/T">subd jan. promo</option>
    <option value="AVANZA 1.5G M/T">subd feb. promo</option>
    <option value="AVANZA 1.5G A/T">subd march promo</option>

  </select>
</p>
<p>
  <select name="type2" style="width:180px">
   <option value="AVANZA 1.3J M/T">subd nov. promo</option>
    <option value="AVANZA 1.3E A/T">subd dec. promo</option>
    <option value="AVANZA 1.3E M/T">subd jan. promo</option>
    <option value="AVANZA 1.5G M/T">subd feb. promo</option>
    <option value="AVANZA 1.5G A/T">subd march promo</option>
  </select>
</p>
<p>
  <select name="type3" style="width:180px">
    <option value="AVANZA 1.3J M/T">subd nov. promo</option>
    <option value="AVANZA 1.3E A/T">subd dec. promo</option>
    <option value="AVANZA 1.3E M/T">subd jan. promo</option>
    <option value="AVANZA 1.5G M/T">subd feb. promo</option>
    <option value="AVANZA 1.5G A/T">subd march promo</option>
  </select>
</p>
<p>
  <select name="type4" style="width:180px">
    <option value="AVANZA 1.3J M/T">subd nov. promo</option>
    <option value="AVANZA 1.3E A/T">subd dec. promo</option>
    <option value="AVANZA 1.3E M/T">subd jan. promo</option>
    <option value="AVANZA 1.5G M/T">subd feb. promo</option>
    <option value="AVANZA 1.5G A/T">subd march promo</option>
  </select>
</p>
<p>
  <select name="type5" style="width:180px">
    <option value="AVANZA 1.3J M/T">subd nov. promo</option>
    <option value="AVANZA 1.3E A/T">subd dec. promo</option>
    <option value="AVANZA 1.3E M/T">subd jan. promo</option>
    <option value="AVANZA 1.5G M/T">subd feb. promo</option>
    <option value="AVANZA 1.5G A/T">subd march promo</option>
  </select>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
        <p>FREE: 
          <input name="chafree" type="text" style="width:100px" />
        </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
<p>&nbsp;</p>
        <p>&nbsp;</p>
</div>
<div id="fourth">
        <p>&nbsp;</p>
<p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>Php: 
      <input name="type1amount" type="text" style="width:120px" />
        </p>
        <p>Php:
          <input name="type2amount" type="text" style="width:120px" />
        </p>
        <p>Php:
          <input name="type3amount" type="text" style="width:120px" />
        </p>
        <p>Php:
          <input name="type4amount" type="text" style="width:120px" />
        </p>
        <p>Php:
          <input name="type5amount" type="text" style="width:120px" />
        </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
    <p>COST: 
      <input name="chacost" type="text" style="width:120px" />
    </p>
        <p>&nbsp;</p>

    <p align="right"><input class="small button blue" type="button" id="Save" name="Save" style="width: 80px" value="Save" /></p>


</div>
</div>
</form>

</body>
</html>

和我的行动表格insert.php

<?php
include("connection.php");

$vsi = $_POST["vsi"];
$date = $_POST["date"];
$custname = $_POST["csname"];
$unit = $_POST["units"];
$color = $_POST["color"];
$consticker = $_POST["consticker"];

$mp = $_POST["mp"];
$grm = $_POST["grm"];
$typetrans = $_POST["typeoftransact"];
$dp = $_POST["dp"];
$amount = $_POST["amount"];
$dirate = $_POST["dirate"];
$typesub1 = $_POST["type1"];
$typesub2 = $_POST["type2"];
$typesub3 = $_POST["type3"];
$typesub4 = $_POST["type4"];
$typesub5 = $_POST["type5"];
$chacost = $_POST["chacost"];
$chapaid = $_POST["chapaid"];
$chafree = $_POST["chafree"];
$type1amount = $_POST["type1amount"];
$type2amount = $_POST["type2amount"];
$type3amount = $_POST["type3amount"];
$type4amount = $_POST["type4amount"];
$type5amount = $_POST["type5amount"];


echo('&nbsp;');
echo('&nbsp;');
echo('&nbsp;');
echo('&nbsp;');
echo('&nbsp;');

if($_POST["Save"]=="Save")
{
$query="INSERT INTO accounts (vsi,date,cname,unit,color,consticker,typetrans,downpayment,amountfinanced,dirate,mp,grm,typesub1,typesub2,typesub3,typesub4,typesub5,chapaid,chacost,chafree,type1amount,type2amount,type3amount,type4amount,type5amount)
VALUES
('".$vsi."','".$date."','".$custname."','".$unit."','".$color."','".$consticker."','".$typetrans."','".$dp."','".$amount."','".$dirate."','".$mp."','".$grm."','".$typesub1."','".$typesub2."','".$typesub3."','".$typesub4."','".$typesub5."','".$chapaid."','".$chacost."','".$chafree."','".$type1amount."','".$type2amount."','".$type3amount."','".$type4amount."','".$type5amount."');";

(mysql_query($query))

or die ("error!".mysql_error() );



}

header('Location: index.php');

?>

3 个答案:

答案 0 :(得分:2)

我不知道validate()方法是否提交了一些ajax。但是,如果我们假设它使用ajax提交,则必须修改你的姓氏,如下所示:

    $("#Save").click(function ()
                 {
                    if (validator.validate())
        /*
if the validate method does not submit the form on success, uncomment the following line

*/
//$('#yourFormId').submit();
                        return;
                      alert("Data Saved!");

                });

答案 1 :(得分:0)

我认为缺少 .submit()

答案 2 :(得分:0)

确保您的表单ID为“FormToValidate”,否则您的代码都不会起作用。另外,请确保您已将动作设置为要提交的文件。

$("#Save").click(function ()
                     {
                        if (!validator.validate())
                           {
                             return;
                            }
                        $('#FormToValidate').submit();
                         alert("Data Saved!");
                          return;

                    });