- 浏览: 1196937 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (706)
- 全部博客(10000) (0)
- java基础 (123)
- 算法及数据结构 (64)
- SSH框架整合与平台系统分析 (11)
- j2ee (46)
- Oracle (95)
- SQL Server (11)
- javaScript (73)
- Ajax (22)
- jQuery (39)
- ExtJs (4)
- jsp (13)
- Servlet (6)
- struts1 (2)
- struts2 (33)
- Ibatis (2)
- hibernate (24)
- Spring (11)
- 设计模式 (8)
- 正则表达式 (9)
- UML (0)
- XML (9)
- linux (19)
- CSS (11)
- FreeMarker (4)
- nginx 与 memcached (6)
- SEO (5)
- Web 服务器 (11)
- junit 与 selenium2 (4)
- MyEclipse 有关的问题 (24)
- 生活杂感 (37)
- 看过的书 (2)
- 技术牛人 (2)
- 需要优化的例子 (3)
- English 学习 (7)
- bug修改的解决方法 (2)
- 数据库实战经验总结 (1)
- 期待解决的问题 (20)
- 等待自己学习的东西 (15)
- 自己公司代码结构总结 (15)
- 企业经营之道 (23)
- 工具管理 (1)
- 世范水晶 (2)
最新评论
-
hustkeai:
第一个方法是不对的
求一个Map中最大的value值,同时列出键,值 -
qq591920734:
java List 排序 Collections.sort() 对 List 排序(首先年龄排序,如果年龄相同,则按名字排序) -
qq591920734:
[color=orange][/color]包女包女不女
java List 排序 Collections.sort() 对 List 排序(首先年龄排序,如果年龄相同,则按名字排序) -
timer_yin:
seagrave 写道这个算法想法不错,但太耗时,我用1、2、 ...
用1、2、2、3、4、5这六个数字,数字排序经典算法 -
hellostory:
日常生活中,我们都不按你上面的那个方法算的!!!
JAVA小函数-计算日期差
<html>
<head>
<script language="javascript">
function checkForm(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var dpassword = document.getElementById("dpassword").value;
if(username.length<6 || username.length>12){
alert("提示:\n\n用户名称必须大于6位,小于12位!");
document.getElementById("username").value = "";
document.getElementById("username").focus();
return false;
}
if(password.length<6 || password.length>12){
alert("提示:\n\n密码必须大于6位,小于12位!");
document.getElementById("password").value = "";
document.getElementById("password").focus();
return false;
}
if(dpassword.length<6 || dpassword.length>12){
alert("提示:\n\n密码必须大于6位,小于12位!");
document.getElementById("dpassword").value = "";
document.getElementById("dpassword").focus();
return false;
}
if(password != dpassword){
alert("提示:\n\n两次输入的密码不同!");
return false;
}
}
</script>
</head>
<body>
<form action="RegisterServlet" method="post">
<div class="fielddiv">
<label>
用户名:
</label>
<input type="text" name="username"/>
</div>
<div class="fielddiv">
<label>
密 码:
</label>
<input type="password" name="password" />
</div>
<div class="fielddiv">
<label>
重复密码:
</label>
<input type="password" name="dpassword"/>
</div>
<div class="center">
<input type="submit" class="buttom" value="注册" onclick="return checkForm()"/>
<input type="reset" class="buttom" value="清空"/>
</div>
</form>
</body>
</html>
为什么onclick中要加上return才能判断成功 才不会继续运行下去。
当直接写onclick="checkForm()" 注册时有错误提示,还是会继续提交给服务器。
解答如下,
JAVASCRIPT在事件中调用函数时用return返回值实际上是对window.event.returnvalue进行设置。
而该值决定了当前操作是否继续。
当返回的是true时,将继续操作。
当返回是false时,将中断操作。
而直接执行时(不用return)。将不会对window.event.returnvalue进行设置
所以会默认地继续执行操作
详细说明如下:
例如:
当在 <a href="abc.htm" onclick="return add_onclick()">Open</a> 中
如果函数 add_onclick() 返回 true, 那么 页面就会打开 abc.htm
否则, (返回 false), 那么页面不会跳转到 abc.htm, 只会执行你的 add_onclick() 函数里的内容. (add_onclick函数中控制页面转到 abc.htm除外
)
而 <a href="abc.htm" onclick="add_onclick()">Open</a>
不管 add_onclick() 返回什么值, 都会在执行完 add_onclick 后打开页面 abc.htm
发表评论
-
jQuery 弹出 div层
2013-11-22 18:58 1020<!DOCTYPE HTML PUBLIC " ... -
匹配数字或包含最多两位小数的数字
2013-11-05 16:24 16751、匹配数字<input onkeyup=" ... -
jQuery学习之prop和attr的区别
2013-07-05 16:34 983.prop() 1、.prop( propertyN ... -
jquery 实现 邮箱的 全选/全不选 全选与全不选功能
2013-07-04 17:43 929<!DOCTYPE HTML PUBLIC " ... -
HTML <input> 标签的 maxlength 属性
2013-06-28 14:45 844HTML <input> 标签的 maxlen ... -
触发 mouseover 事件和 mouseenter 事件 的区别
2013-06-17 15:02 1161来源: http://www.w3school.com.c ... -
js清除input中type等于file的值域
2013-05-20 15:19 589js清除input中type等于file的值域 ... -
如何用js控制img中src图片路径改变
2013-05-15 16:39 6769下边是一列小图片(src图片路径是动态生成的)上边有一个di ... -
<input type="file" id="fileID">这个文本框里的值 怎么清空啊?
2013-05-15 15:30 1007来源: <input type="fil ... -
多个图片上传 js 预览功能
2013-05-15 14:44 20075一 、方法1 来源:ht ... -
单个图片上传 js 预览图片 功能
2013-05-02 19:05 1160方法1、 <!DOCTYPE HTML PU ... -
取字符串中的数字,汉字,去掉字符串空格
2013-04-09 11:58 1036<html> <head> < ... -
js 放在html 的位置 不同 造成的结果页不相同
2013-02-18 16:56 1964例子1、代码可以正常执行: <%@ page lan ... -
Jquery通过JSON和Struts的Action交互
2012-10-24 20:59 7941、Jquery通过JSON和Struts的Action交互 ... -
IE6下<a href="#">与<a href="javascript:void(0);">的区别
2012-08-09 11:41 8881、点击下面连接 IE6下<a href=&quo ... -
JS中encodeURI,escape,encodeURIComponent区别
2012-07-30 09:53 1151JS中encodeURI,escape,encodeURI ... -
设置editplus的编码格式
2012-07-22 23:54 8913方法1、设置editplus的编码格式,如下图: ... -
对file输入框的美化,换成图片的形式
2012-06-14 16:20 1256重点代码如下: http://topic.csdn.n ... -
js 中的onselect 与jQuery中的select 事件的用法
2012-05-03 15:12 32501、 jQuery 的用法如下: <!DO ... -
如何通过JS 给一个ID添加触发事件?
2012-05-03 12:16 1868<!DOCTYPE html> <html ...
相关推荐
}}够了吧 屏蔽右键 很酷 oncontextmenu="return false" ondragstart="return false" onselectstart="return false"加在body中二2.1 表单项不能为空<script language="javascript"><!--function CheckForm(){ if...
checkform.js对一般的表单验证进行了封装,方便实用
form id=login-form method=post onsubmit=return checkForm()> 输入密码<input type=password id=input-password> <input type=hidden id=md5-password name=password> <button type=submit&...
js 验证页面 checkform 验证页面的js代码
form id=login-form method=post onsubmit=return checkForm()> 输入密码<input type=password id=input-password> <input type=hidden id=md5-password name=password> <button type=submit&...
用原生JS写一个简单的表单验证 ... <div class=divAll> ... <div id=contents> ...form action=# onSubmit=return checkForm()> <div id=form-itemGroup> <label for=userName>用户名: <input type=
Dreamweaver CHECKFORM.MXP 插件
jquery-checkform
action=add" onSubmit="return checkform(form1)"> <table width="500" height="241" border="0" cellpadding="0" cellspacing="0"> <td width="131" align="center">歌曲类别: <td width="369"> ...
本文实例为大家分享了js实现用户注册功能的具体代码,供大家参考,具体内容如下 1.HTML代码结构 <BODY> <FORM action="success.html" method="post" name="myform" onSubmit="return checkForm()"> border=...
<input type="button" value="test" onclick="check()"> function check() { with(document.all){ if(input1.value!=input2.value) { alert("false") input1.value = ""; input2.value = ""; } else document....
CheckForm.js 常用表单javascript验证
加在body中 二 2.1 表单项不能为空 [removed] <!-- function CheckForm() { if (document.form.name.value.length == 0) { alert("请输入您姓名!"); document.form.name.focus(); return false; } ...
1、步骤分析 第一步:确定事件(onsubmit)并为其绑定一个函数 ...onsubmit = return checkForm() 2、完成注册页面表单校验 <!DOCTYPE html> <html> <head> <meta charset="UTF-8">
checkform-for.netcheckform-for.net
适合新手的简单的表单验证,纯js编写,适合js初学者练习
* 请勿在未经授权的情况下上传任何涉及著作权侵权的资源,除非该资源完全由您个人创作 * 点击上传资源即表示您确认该资源不违反资源分享的使用条款,并且您拥有该资源的所有版权或者上传资源的授权 ...
很小巧的一个JS验证框架。
var flag = checkForm(); if (flag == false) { return; } $.ajax({ //几个参数需要注意一下 type: "POST",//方法类型 dataType: "json",//预期服务器返回的数据类型 url: "<%=path %>
dw 插件 checkform 非常使用的DW插件