日期:2014-05-17  浏览次数:20490 次

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"   />&nbsp;&nbsp;</td>
     </tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="INSERT" name="submit" class="submit"  />&nbsp;&nbsp;
<input type="button" value="BACK TO LIST" name="back"  />
</td>
</tr>
    </table>
    </form>

------解决方案--------------------
$.validator.setDefaults({
submitHandler: function() { alert("submitted!" ; website.submit(););
}
});

出掉试下