JavaScript中 confirm的问题

来源:百度知道 编辑:UC知道 时间:2024/05/21 10:46:08
<head>
<script>

function thereset()
{
if(confirm("是否需要清除?"));
}

function thesubmit()
{
if(confirm("是否需要提交?"));
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>

<form name="form1" method="post" action="" onReset="return thereset()" onSubmit="return thesubmit()">
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重写">
<input type="text" name="textfield">
<input type="radio" name="radiobutton" value="radiobutton" CHECKED>

<input type="radio" name="

由於你上面confirm后只是进行判断没有return或发出其它动作,所以不管怎麼样他都提交了,我给你修改了一下
<head>
<script>

function thereset()
{
return confirm("是否需要清除?");
}

function thesubmit()
{
return confirm("是否需要提交?");
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>

<form name="form1" method="post" action="" onReset="return thereset()" onSubmit="return thesubmit()">
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重写">
<input type="text" name="textfield">
<input type="radio" name="radiobutton" value="radiobut