我有html步骤表单,我需要在表单通过验证并填写所有字段后提交表单。我有一个动作控制器register.php,但在我的html表单中,我也有action =“ javascript:void(0) ;“所以我该如何提交表单动作。
<div class="form-bottom">
<div class="row">
<div class="form-group col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12">
<input type="text" class="form-control" placeholder="addres 1" id="add1" name="" value="" |>
</div>
<div class="form-group col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12">
<input type="text" class="form-control" placeholder="address 2" id="add2" name="" value="">
</div>
<div class="form-group col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12">
<input type="text" class="form-control" placeholder="city" id="city" name="" value="" |>
</div>
</div>
<div class="row">
<div class="form-group col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12">
<input type="text" class="form-control" placeholder="Home Phone" id="contact_number" name="" value="">
</div>
</div>
<div class="form-group col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12">
<input type="checkbox" name="vehicle" value="Car" checked> I Agree<br>
</div>
<button type="button" class="btn btn-previous">Previous</button>
<button type="submit" class="btn">Submit</button>
</div>
答案 0 :(得分:-1)
您可以使用ajax查询将数据发送到php脚本。
该代码插入onsubmit函数中
var formData = $(form_selector).serialize(); //Getting data from form
$.ajax({
type: "POST",
url: URL to php script,
data: formData,
success: function(data) {
//Action if data successfully sended, it's not nessesary
}
});
上了解有关jQuery ajax的更多信息