表单非空校验

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>非空校验</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<script type="text/javascript">
$(function(){
$(":text").blur(function(){
if($(this).val().length<=0){
$(this).css("background","red");
}else{
$(this).css("background","white");
}
})
})
</script>
</body>
</html>

原文地址:https://www.cnblogs.com/nifengs/p/4800091.html