// 种种原因 后台要写些前端的东西~ 记录一下
JS 判断表单项不能为空代码
<script type="text/javascript">
function check(form){
var y=document.getElementById("form2");
for(var i = 0;i < y.length-1;i++)
{
//当前表单所有input不能为空
if(y[i].value == null || y[i].value == "" || y[i].value == "undefined")
{
alert( y.length +"1"+ y[1].value + "2"+y[2].value + "所有栏目必须填写!请检查!");
//一进入页面将光标定位到第一个input
y[i].focus();
return false;
}
}
return true;
}
</script>