Bootstrap validator.js没有与我的PHP通信

时间:2017-03-01 15:30:30

标签: javascript php jquery ajax twitter-bootstrap

我是新手编码器,我在使用validator.js将简单表单​​放在一起时遇到问题

基本上,由于尝试构建验证表单已停止工作,我的猜测是'数据:$(' #send-form')。serialize(),'没有正确的路径或语法,但我可能是错的。

我加上:

$.ajax({
type: "POST",
url: "process.php",
data: $('#send-form').serialize(),
}

警报不会触发!



<form class="contact" name="contact" id="send-form" data-toggle="validator" role="form"  >


  <div class="form-group">
    <label class="subTitle" for="name">NAME</label><br>
    <input type="text" name="name" class="form-control" placeholder="Enter your full name" data-error="Please enter your name" required>
    <div class="help-block with-errors"></div><br>
  </div>

  <div class="form-group">
    <label class="subTitle" for="email">E-MAIL</label><br>
    <input type="email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" class="form-control" placeholder="Enter a valid email address" data-error="Invalid email address" required>
    <div class="help-block with-errors"></div><br>
  </div>

    <div class="form-group">
      <button type="submit" class="subBtn form-control">SUBMIT YOUR ENQUIRY</button>
    </div>

</form> 




    



<script>
$('#send-form').validator().on('submit', function (e) {
    if (e.isDefaultPrevented()) {
        alert('form is not valid');
    } else {
        // everything looks good!
        e.preventDefault();
        alert('form is valid');
        // your ajax
                $.ajax({
                type: "POST",
                url: "process.php",
                data: $('#send-form').serialize(),
                }
});

</script>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

应该是:

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    self.applyFilter(index: row)
    return pickerFilters[row]
}

(未测试的)