我在我的網站項目,似乎我的jQuery功能不起作用 。我必須驗證這一點:如果用戶輸入<<nom de famille du pere>>
,<<prenom du pere>>
也必須輸入too.This是我的html代碼:提交按鈕的jQuery表單驗證
<div class="form-group">
<div class="col-md-6">
<label class="col-md-4 control-label" for="father">Nom de famille du père </label>
<input id="father" name="father" type="text" class="form-control input-md" >
</div>
</div><br/><br/><br/>
<div class="form-group">
<div class="col-md-6">
<label class="col-md-4 control-label" for="ffather">Prénom du père</label>
<input id="ffather" name="ffather" type="text" class="form-control input-md">
</div>
</div><br/><br/><br/>
,這是我的jQuery功能:
$(document).ready(function() {
$('#father').submit(function() {
if ($(this)).is(':empty')) {
\t $('#ffather').prop('required',false);
\t
\t
}
else{
\t $('#ffather').prop('required',true);
\t
\t
}} }
如何提交輸入? – adeneo
在窗體上設置'.submit()'處理程序,而不是輸入;或者在輸入 – Plato
上使用'.change()'或'.keyup()',我忘記將表單頭放在代碼中,並且我也有一個提交按鈕 – user3430205