javascript先判断,再提交!

来源:百度知道 编辑:UC知道 时间:2024/05/21 07:03:50
<button class=btn3_mouseout onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'"
onmousedown="this.className='btn3_mousedown'"
onmouseup="this.className='btn3_mouseup'"
title="提交" onClick="test1(this.form)" type="submit">提交</button>这是一个提交按纽,上面有我的javascript判断是否文本框为空,可每次判断为空的时候,整个页面都刷新了,如何可以让他先整个都判断完了,再提交页面呢?
还是不行,还有别的方法吗?

页面type="button"
js里面
文本框里面先判断document.forms[0].elements[txtName].value=""
然后手动提交
document.forms[0].action="xxxx";
document.forms[0].submit();

type类型改成button,然后在js里面执行提交操作

onClick = "return test1(this.form)"

在test1函数中判断为空时返回False即可

我和3楼想法一样