我已经为我的表单添加了jquery验证插件。以下是js文件的链接。
<script src="<?php echo base_url();?>jquery/dist/jquery.min.js"></script>
<script src="<?php echo base_url();?>jquery/dist/jquery.js"></script>
<script src="<?php echo base_url();?>jquery-validation/dist/jquery.validate.js"></script>
<script src="<?php echo base_url();?>jquery-validation/dist/jquery.validate.min.js"></script>
此外,我还在头部添加了以下脚本。
<script type="text/javascript">
$(document).ready(function(){
$('#new_customer_form').validate();
});
</script>
我的表格如下。
<form id="new_customer_form" method="post" action="<?php echo base_url();>index.php/customer/insert_newcustomer_db">
<div class="form-group">
<label for="customer_name" class="control-label">Customer Name </label>
<input type="text" id="customer_name" name="customer_name" class="form-control" placeholder="Enter customer name" required/>
</div>
<div class="form-group">
<label for="address" class="control-label">Address </label>
<input type="text" id="address" name="address" class="form-control" size="20" placeholder="Enter customer address" required/>
</div>
<div class="form-group">
<label for="tele" class="control-label">Contact number</label>
<input type="text" id="tele" name="tele" class="form-control" placeholder="Enter your Contact number" required/>
</div>
<tr>
<th align="right" scope="row"> </th>
<td><input type="submit" name="submit" value="Submit" /></td>
</tr>
</form>
但我的表格接受我输入的任何内容。谁能看到错误?
Firebug会出现这些错误。Firebug consoler