form的OnSubmit和input type=image使用介绍
2016-06-21来源:易贤网

这里如果有input type=image 那么直接按这个图像后会提交表单, 如果有OnSubmit会先执行这个函数,感兴趣的朋友可以看下这个例子

这里如果有<input type="image"> 那么直接按这个图像后会提交表单,

如果有OnSubmit会先执行这个函数,如果返回false则不提交表单!

代码如下:

<span style="font-size:14px;"><script language=javascript>

function test()

{

alert("测试!")

}

</script>

<form name="F1" onSubmit="fuck();">

<input type="image" src="" width="51" height="20">

</form></span>

另外一个示例:

代码如下:

<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>

2025公考·省考培训课程试听预约报名

  • 报班类型
  • 姓名
  • 手机号
  • 验证码
推荐信息