jQuery规则验证远程成功表单未提交

时间:2018-10-09 08:00:15

标签: jquery validation

我使用jQuery验证来验证zoneForm。验证工作正常,但$('#zoneForm').submit();无效。我在这里使用内部js。这是我的代码 list.php

<form id="zoneForm" name="zoneForm" method="POST" action="<?php echo site_url('zone/zoneadd');?>">
   <label>Zone Name</label>
   <input type="text" class="form-control zoneName" id="zoneName" name="zoneName" placeholder="Enter Zone Name" required />
</form>

$("#zoneForm").validate({
    rules: {
        'zoneName': {
            minlength: 4,
            maxlength: 15,
            remote: {
                url: '<?php echo base_url();?>zone/zoneCheck',
                type: "POST",
                success: function(data) {
                    if (data == 0) {
                        $('#zoneForm').submit();
                    } else {
                        alert('Zone already Exist...!');
                        location.reload();
                    }
                }
            }
        }
    },
    validClass: "success",
    highlight: function(element) {
        $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
    },
    success: function(element) {
        $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
    },
    submitHandler: function(e) {

    },
});

zone.php

public function zoneCheck(){
    $data = $this->input->post();
    $result = $this->zone_model->getzoneCheck($data);
    if($result == 1)
    {
        echo TRUE;  
    } 
    else if($result == 0)
    {
        echo 0;
    } 
}
  

$('#zoneForm').submit();未提交

0 个答案:

没有答案