html页面:
<form action="list.html" method="post" onsubmit="return check()">
<input type="text" id="mid" >
</form>js代码:
function check(){
if($("#mid").val==""){
alert("不能为空");
return false;
}
return true;
}
本文介绍了一个简单的HTML表单验证示例,通过JavaScript实现对输入框的非空检查。当用户提交表单时,如果输入框为空,则弹出提示框并阻止表单提交。
html页面:
<form action="list.html" method="post" onsubmit="return check()">
<input type="text" id="mid" >
</form>function check(){
if($("#mid").val==""){
alert("不能为空");
return false;
}
return true;
}
被折叠的 条评论
为什么被折叠?