<html>
<head>
<title>forms example</title>
</head><body>
<form action="welcome.php" method="post">
姓名:<input tpye="text" name="name"><br>
年龄:<input type="test" name="age"><br>
<input name="submit" type="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</body>
<html>如果name test为空,就弹出一个窗口(提示name 框为空),or age test 为空,也弹出一个窗口目前正在学PHP,请各位帮帮忙,不是我不google和百度,只是这种问题知道怎么用google找??
<head>
<title>forms example</title>
</head><body>
<form action="welcome.php" method="post">
姓名:<input tpye="text" name="name"><br>
年龄:<input type="test" name="age"><br>
<input name="submit" type="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</body>
<html>如果name test为空,就弹出一个窗口(提示name 框为空),or age test 为空,也弹出一个窗口目前正在学PHP,请各位帮帮忙,不是我不google和百度,只是这种问题知道怎么用google找??
解决方案 »
- 如何正确统计网站来路
- 急!Apache+php+mysql的XML输出返回问题
- ISAPI_Rewrite 防盗链的正则问题. 150分(全部的分都压上了)
- 关于验证码提交后的判断问题
- 如何才能把查询出来的结果以数组的形式输出....
- 一个数据库连接问题,哪位遇到过,请多多指教,谢谢啦
- 怎么把一个二维数组中符合条件的值存到一个新的二维数组中
- 这段用命令运行的PHP脚本 查询语句可以怎么优化
- 再次送上100分~~~~同时指出唠叨老兄的一个小错误!(关于关于UTF-8编码下的简体繁体动态转换)
- 前辈,关于提交留言到mysql,中文变乱码的问题。
- 请问php怎么在已有的xml文件上编写?
- php数据库问题(在线等)
<form>里加上onclick 变成 <form action="welcome.php" method="post" onsubmit="return check()">
然后写个js方法:
function check(){
if(...){ //验证
return true;
}else{
return false;
}
}
<head>
<title>表单验证</title>
</head><script type="text/javascript">
function checkInput()
{
var name = document.form1.name.value;
var age = document.form1.age.value;
if(name == ""){
alert("用户不能为空!");
document.form1.name.focus();
return false;
}
if(age == ""){
alert("密码不能为空!");
document.form1.age.focus();
return false;
}
return true;
}
</script><body>
<form name=form1 action="welcome.php" method="post" onsubmit="return checkInput()">
姓名:<input tpye="text" name="name"><br>
年龄:<input type="test" name="age"><br>
<input type="submit" name="submit" value="提交" />
<input type="reset" name="reset" value="重置" />
</form></body>
<html>
还是谢谢各位
function check(){
if(document.getElementById("文本框id").value == ""){
alert("不能为空");
}
}
</script>
function check(){
if(document.getElementById("文本框id").value == ""){
alert("不能为空");
}
}
</script>