form的OnSubmit和<input type="image">
2013-09-05 23:56
609 查看
这里如果有<input type="image"> 那么直接按这个图像后会提交表单,
如果有OnSubmit会先执行这个函数,如果返回false则不提交表单!
另外一个示例:
<html>
</head>
<script language="javascript">
function checkEmpty(form){
for(i=0;i<form.length;i++){
alert(form.elements[i].value);
if( form.elements[i].value=="" ){
alert("表单信息不能为空");
return false;
}
}
}
</script>
<body>
<form name="form" method="post" onSubmit="return checkEmpty(form)">
<input name="name" type="text" size="17">
<input name="password" type="password" size="17">
<input type="image" src="" width="51" height="20">
<input type="button" value="AAA" />
</form>
</body>
<html>
如果有OnSubmit会先执行这个函数,如果返回false则不提交表单!
<script language=javascript> function test() { alert("测试!") } </script> <form name="F1" onSubmit="fuck();"> <input type="image" src="" width="51" height="20"> </form>
另外一个示例:
<html>
</head>
<script language="javascript">
function checkEmpty(form){
for(i=0;i<form.length;i++){
alert(form.elements[i].value);
if( form.elements[i].value=="" ){
alert("表单信息不能为空");
return false;
}
}
}
</script>
<body>
<form name="form" method="post" onSubmit="return checkEmpty(form)">
<input name="name" type="text" size="17">
<input name="password" type="password" size="17">
<input type="image" src="" width="51" height="20">
<input type="button" value="AAA" />
</form>
</body>
<html>
相关文章推荐
- JS禁止FORM的<input type="submit" />提交的方法--测试过--非常有用
- <input type = "submit"> 提交方式和用js的form.submit()有什么区别?
- <input type = "submit"> 提交方式和用js的form.submit()有什么区别?
- form的OnSubmit和input type=image使用介绍
- <input type="image">标签引发的form表单自动提交
- <button></button> 与<input type="button"> <input type="submit">
- <input type="submit">点击按钮 添加内容到相应的radio的ul li中
- <input type="image"> 和 <img> 用法区别
- An invalid form control with name='file[]' is not focusable.间接点击form表单的<input type="file">出现的问题
- <input type="submit" name="Submit" value="提交" />添加网站跳转的两种方式小结
- <a>标签内嵌<input type="image">在IE中链接失效问题
- <input type = "submit"> 提交方式和用js的form.submit()有什么区别?
- 表单按回车自动提交 1、当form表单中只有一个<input type="text" name='name' />时按回车键将会自动将表单提交。 <form id='form1' action='a
- Webview响应简单的<input type="submit" value="Submit">
- <input type="file">系列文章一(上)
- form表单中的input type="submit"
- 解析<button>跟<input type="button"> 的区别
- <input type="radio" >与<input type="checkbox">值得获取
- <input type="file" />浏览时只显示指定文件类型
- <input type="image"> 和 <img> 用法区别