Jquery验证表单
<script type="text/javascript" src="<?=base_url()?>assets/js/jquery.js"></script>
<script type="text/javascript" src="<?=base_url()?>assets/js/jquery.validate.js"></script>
<script language="javascript" >
$.validator.setDefaults({
submitHandler: function() { alert("submitted!" ; website.submit(););
}
});
$(document).ready(function() {
// validate the website form when it is submitted
//$("#website").validate();
$("#website").validate({
rules: {
companytheme: "required"
},
messages: {
companytheme: "This field is required."
}
});
});
</script>
<form name="website" enctype="multipart/form-data" action="<?=base_url()?>admin/insert_website" method="post" id="website" >
<table style="font-size:12px;" class="addwebsite">
<tr>
<td width="150">Company Theme:</td>
<td><input type="text" value="" style="width:270px;" name="companytheme" id="companytheme" /> </td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="INSERT" name="submit" class="submit" />
<input type="button" value="BACK TO LIST" name="back" />
</td>
</tr>
</table>
</form>
------解决方案--------------------$.validator.setDefaults({
submitHandler: function() { alert("submitted!" ; website.submit(););
}
});
出掉试下