我有一个由Vapor创建的页面,以.leaf呈现。使用bootstrap。
页面有一个表单,该表单由行组成,每行包含5个输入字段:
5
<form>
#loop(line_items, "line_item") {
<div class="form-group row" id=#(line_item.id)>
<div class="col col-sm-1">
<input type="checkbox" class="form-control form-control-sm checkbox" name="plan">
</div>
<div class="col col-sm-2">
<input type="date" class="form-control form-control-sm" name="deadline">
</div>
<div class="col col-sm-2">
<select class="form-control form-control-sm" >
<option id=0>Not assigned</option>
#loop(users,"user") {
<option id=#(user.id)>#(user.name)</option>
}
</select>
</div>
<div class="col col-sm-3">
<input type="text" class="form-control form-control-sm" >
</div>
<div class="col col-sm-1">
<input type="time" class="form-control form-control-sm" value=#(line_item.line_item/amount)>
</div>
<div class="col col-sm-3">
#(line_item.description)
</div>
</div>
}
<button type="submit" class="btn btn-primary" id="submit-button">Create Tasks</button>
<button type="submit" class="btn btn-secondary">Cancel</button>
</form>
我想验证:
我正在使用:
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.3.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>
<script src="validation.js"></script>
并且在那个validation.js中我将编写要求(我和他们玩了一下,除了上面的两个问题外,它很棒)
回应Tyan Tuosto:没有真正的代码可以玩:
$(function() {
$("#task-form").validate({
rules : {
deadline: {
required: true
}
}
});
})