0
我正在使用ajax和JSON将信息检索到表单中。但是,用户可以编辑这些字段,但新数据不会去任何地方。我需要对字段进行验证,但不知道如何在不添加HTML表单中的“操作”部分中添加外部文件的情况下工作。谢谢你的帮助。静态表单上的jQuery验证
我的HTML
<form id="summary" method="get" action="">
<h2>Summary Form</h2>
<label for="firstname">First Name</label>
<input type="text" name="firstname" id="firstname" placeholder="First name"/>
<label for="lastname">Last Name</label>
<input type="text" name="lastname" id="lastname" placeholder="Last Name"/>
<label for="email">Email</label>
<input type="email" name="email" id="email" placeholder="Email"/>
<label for="roomtype">Room Type</label>
<input type="text" name="roomtype" id="roomtype" placeholder="Room Type"/>
<div id="datepicker"></div>
<label for="checkin">Checkin</label>
<input type="text" name="checkin" id="checkin" placeholder=" Check in"/>
<label for="checkout">Checkout</label>
<input type="text" name="checkout" id="checkout" placeholder=" Check out"/>
<label for="noofnights">Number of nights</label>
<input type="number" name="noofnights" id="noofnights" placeholder="Number of nights"/>
<label for="totalstay">Total Stay </label>
<input type="number" name="totalstay" id="totalstay" placeholder="Total stay"/>
<button type="button">Update</button>
<button type="button" id="button1">Book</button>
MY jQuery验证
$(function() {
$("form[id='summary']").validate({
rules: {
firstname: "required",
lastname: "required",
email: {
required: true,
email: true
},
},
// validation error messages
messages: {
firstname: "Please enter your firstname",
lastname: "Please enter your lastname",
email: "Please enter a valid email address"
},
submitHandler: function(form) {
form.submit();
}
});
});
我想这一点,但是当我点击“更新”按钮,它只是刷新页面并没有表现出任何到位 – Smith
这个插件是否加入到源代码中? –
该插件不再可用。我有 – Smith