我就是想提交表单时进行验证,但是javascript不能进行验证,试过把onsubmit="return checkfm(this)">改为onsubmit="return checkfm(this.form)">了,不行;试过把onsubmit="return checkfm(this)">改为onsubmit="return false"> 就不能提交表单了;但问题出在哪里呢?[img][/img][code="java"]
<%@ page contentType="text/html;charset=utf-8"%>
<%@ include file="/admin/share/taglib.jsp" %>
添加类别 function checkfm(form) { if(trim(form.name.value)=="") { alert("类别名称不能为空!"); form.name.focus(); return false; } if(byteLength(form.mote.value)>200) { alert("备注不能大于100字!"); form.note.focus(); return false; } return true; }
添加类别: | |
类别名称: |
* |
备注(100字以内): |
|
[/code]
[b]问题补充:[/b]
谢谢你 lovewhzlq (CTO),
第一 你把return ture去掉,这句不影响程序啊,如果前面返回false,return ture 是不执行的;
第二 你把retrun 去掉,我在网上查了查,不加return是不对的吧。
你说呢,谢谢你的回答^_^
[b]问题补充:[/b]
谢谢Sonnow的回答。
这几天我也一直在考虑这个问题,现在问题解决了。
是这样的我传的值是onsubmit="return checkfm(this)"> ,我后来改为了onsubmit="return checkfm(this.form)"> 也不行,后来我用了onclick="return checkfm(this.form)"> 就可以了,
后来我又改为了onsubmit="return checkfm(document.forms[0])">也行了,我爱听”后来“,呵呵,谢谢二位了。
[b]问题补充:[/b]
知道上面是怎么回事吗??