<html>
<head>
<title>New Page 1</title>
</head>
<script>
function check(){
if(parseFloat(document.all.a.value)<2||parseFloat(document.all.b.value)==0){
alert("error!")
event.returnValue = false;
}
else
event.returnValue = true
}
</script>
<body>
<form method="POST" action="" onsubmit="check()">
<p>值1:<input type="text" name="a"></p>
<p>值2:<input type="text" name="b"></p>
<p><input type="submit" value="Ìá½»" name="B1"></p>
</form>
</body>
</html>
<head>
<title>New Page 1</title>
</head>
<script>
function check(){
if(parseFloat(document.all.a.value)<2||parseFloat(document.all.b.value)==0){
alert("error!")
event.returnValue = false;
}
else
event.returnValue = true
}
</script>
<body>
<form method="POST" action="" onsubmit="check()">
<p>值1:<input type="text" name="a"></p>
<p>值2:<input type="text" name="b"></p>
<p><input type="submit" value="Ìá½»" name="B1"></p>
</form>
</body>
</html>
解决方案 »
- js 设置样式时,能否整体设置?如document.getElementById("div2").style=整个样式
- 求去掉HTML代码中空白段落的正则表达式
- 多首音乐连续播放问题??????
- 问一个Javascript代码顺序的问题
- javascript问题
- 怎样禁用TAB键?比如让<input id='text1' type='text'>禁用TAB.
- Javascript如何控制直接在默认的打印机上打印
- 请教!为什么,我用JavaScript做页面跳转的时候问题。
- 各位兄弟帮忙
- 求:jsp在线显示pdf,并禁止下载,另存。最好可以实现页码跳转,获取当前页码
- 难题:刷新能不能没声音啊??
- <script src="XXX"></script>这样形式调用脚本是否在网页下载的时候就下载
然后做验证
function yanzhen(){
if (a.value<2){
alert()
returen flase}
if (b.value=0){
alert()}
return true
}喝酒了,大概是这样。你改一下应该可以。:)
<form method="POST" action="" onsubmit="return on_submit()">,那么check()放在哪里啊?呵呵