判断表单中的文本框的内容是否为空的方法有很多:1.通过php语句判断 2.通过js语句判断 3.通过html原生语句进行判断。
1.通过PHP语句判断 :
html中内容:
php中内容://submit.php
if(isset($_POST['text']) && strlen(trim($_POST['text']))>0)
echo '不空';
else
echo '空 ';
?>
2.通过JS语句判断
JS判断input是否为空if(document.getElementById("ip").value==""){
alert("input为空");
}else{
alert(document.getElementById("ip").value);
}
}
3.通过required属性判断
表单账号: