javascript简单验证
<html>
<head>
<base href="<%=basePath%>">
<script type="text/javascript">
function check(){
var name1 = document.form1.name1.value;
var password1 = document.form1.password1.value;
var email = document.form1.email.value;
if(name1 == ""){
alert("用户名不能为空!");
return false;
}
else if(password1.length<4 || password1==""){
alert("密码不能少于4位");
return false;
}else {
var idxEmail = email.indexOf('@');
if(idxEmail <=0 || idxEmail == email.length - 1){
alert("Email地址格式不合法");
return false;
}
}
}
</script>
</head>
<body>
<form action="registerOK.jsp" method="post" name="form1" onsubmit="return check()">
<input type="text" name="name1"/>
<input type="password" name="password1"/>
<input type="text" name="email" />
<input type="submit" value="提交">
</form>
</body>
</html>
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
marquee滚动标签的javascript(jquery)替代品:jquery.marquee插件(http://remysharp.com/tag/marquee) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999 ......
每一项都是js中的小技巧,但十分的实用!
1.document.write(""); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document->html->(head,body)
4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById("表单中元素的 ......
//转换为UNIX时间戳
function strtotimestamp(datestr)
{
var new_str = datestr.replace(/:/g,"-");
new_str = new_str.replace(/ /g,"-");
var arr = new_str.split("-");
var datum = new Date(Date. ......