This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 谢谢DX们,再问个问题,做了一个输入form,填了一个内容按回车就自动SUBMIT了,怎么屏蔽这个,使它只有当按指定的按钮的时候才提交?
-haihai(海海);
2002-10-29
(#823753@0)
-
I think you have to separate the submit button into a separate form. Or make your textbox into textarea and wrap it soft, so it allows enter...
-jeffrey815(Smartiecat);
2002-10-29
(#823785@0)
-
OK,试验一下
-haihai(海海);
2002-10-29
(#823945@0)
-
Write a Javascript function and set it in onSubmit handler. In the function, check if the activating event is clicking, if yes, submit the form, if no, just ignore it.
-rudy2000(born in 1975);
2002-10-29
(#823819@0)
-
won't work. onsubmit event is after clicking the button.
-jeffrey815(Smartiecat);
2002-10-29
(#823851@0)
-
onsubmit好象也可以的
-haihai(海海);
2002-11-1
(#830213@0)
-
example<html>
<head>
<script type="text/javascript">
function validate()
{
x=document.myForm
txt=x.myInput.value
if (txt>=1 && txt<=5)
{
return true
}
else
{
alert("Must be between 1 and 5")
return false
}
}
</script>
</head>
<body>
<form name="myForm" action="tryjs_submitpage.htm" onsubmit="return validate()">
Enter a value from 1 to 5:
<input type="text" name="myInput">
<input type="submit" value="Send input">
</form>
</body>
</html>
-haihai(海海);
2002-11-1
{493}
(#830223@0)
-
What's this got to do with your enter key problem??
-jeffrey815(Smartiecat);
2002-11-1
(#830361@0)
-
啊。。。好象是有点混乱了,这个是用来检查一些非法输入的,不行的话就不SUBMIT。我是用楼下的兄弟讲的改成BUTTION来解决回车键\的问题的。呵呵,SORRY
-haihai(海海);
2002-11-1
(#830604@0)
-
if you are using VC++, overwrite OnOK().
-lusi(丑小鸭);
2002-10-29
(#823845@0)
-
he's dealing the html.
-jeffrey815(Smartiecat);
2002-10-29
(#823856@0)
-
是啊,用HTML和SCRIPT LANGUAGE
-haihai(海海);
2002-10-29
(#823941@0)
-
try this...<script language="JavaScript">
document.onkeypress = doKeyEvent;
function doKeyEvent(){
if (event.keyCode==13) // [Enter] Key pressed
return false;
}
</script>
-leoxie(Leo);
2002-10-29
{184}
(#824821@0)
-
不要submit键,让所有的按键都是普通button,再在onbutton_click里做完你要的工作后写上 formname.submit;
-liding_wang(无坚不摧大砍刀);
2002-10-30
(#825611@0)