现在有一个表单,有用户名,密码,邮箱,如果信息不写,提交按纽不可用,如果全写了才可用,这种的代码怎么写啊。高手指点一下。
解决方案 »
- 要做一个售卖虚拟物品的C2C网站,请各位大侠说说用什么开源项目修改最好?
- 急求 php的图片显示 , 谢谢
- 求php+ajax上传图片的实例!!!!!!!!!!!!!!!!!!!!!用的不是files,点击<a href="">上传图片</a>的时候,就弹出选择本地图
- 如果读取图片上的数字
- 配置zencart PHP中没有编译CURL
- PHP bluePage类分页的问题
- 爱查快递的API如何申请
- PHP中使用memcache报错,无法找到此类
- 求助,discuz x3如何通过url提交模拟表单提交(回帖)
- PHP中的一个DB类中的成员方法为什么 可以 当作静态方法使用!求指点?
- linux+apache+php+mysql 支持的最大并发量是多少
- 请教关于$_POST值时有时无的问题
用户名:<input type="text" name="username" />
密码:<input type="password" name="pwd" />
邮箱:<input type="text" name="email" />
<input type="submit" name="submit" value="提交" />
</form><script language="javascript">
function checkform(obj){
if(obj.username.value==''){
alert("用户名不能为空");
obj.username.focus();
return flase;}
if(obj.pwd.value==''){
alert("密码不能为空");
obj.pwd.focus();
return flase;
}
if(obj.email.value==''){
alert("邮箱不能为空");
obj.email.focus();
return flase;
}}
</script>
你要的是不是这个,希望对你有用
<script language="javascript">
function checkform(){
var obj = document.all.myform ;
if(obj.username.value!='' &&obj.pwd.value!='' &&obj.email.value!=''){
obj.submit.disabled = false ;
} else {
obj.submit.disabled = true ;
}
}
</script><form name="myform" id="myform" action="" method="post" >
用户名:<input type="text" onKeyUp="checkform()" name="username" />
密码:<input type="password" onKeyUp="checkform()" name="pwd" />
邮箱:<input type="text" onKeyUp="checkform()" name="email" />
<input type="submit" disabled="true" name="submit" value="提交" />
</form>
//根据ID获取元素
function $(id){
if(id)return document.getElementById(id);
}
//检查是否输入值
function checkform(){ if($('username').value!='' && $('pwd').value!='' && $('email').value!=''){
$('sub').disabled = false ;
} else {
$('sub').disabled = true ;
}
}
</script><form name="myform" id="myform" action="" method="post" >
用户名:<input type="text" onKeyUp="checkform()" id="username" />
密码:<input type="password" onKeyUp="checkform()" id="pwd" />
邮箱:<input type="text" onKeyUp="checkform()" id="email" />
<input type="submit" disabled="true" id="sub" value="提交" />
</form>