Posts Tagged ‘JS’

常用JS表单验证汇总(持续更新)

星期五, 六月 7th, 2013 16 views

首先是测试html页面的编写

1
2
3
4
5
6
7
8
<form name="form1" action="#" method="post" onsubmit="return check()">

帐号:<input name="ID" type="text" />
密码:<input name="PWD" type="password" />
<input name="submit" type="submit" value="提交" />  
<input name="reset" type="reset" value="取消" />

</form>

以下为相应功能的js脚本
①验证为非空

1
2
3
4
5
6
7
8
9
10
function check()
{
    if(document.form1.ID.value=="" || document.form1.PWD.value=="" )
    {
        alert("用户名或密码不能为空!");
        this.form1.ID.focus();
        return false;
    }
else form1.submit();
}

②密码位数验证

1
2
3
4
5
6
7
//添加进check()中即可
if(document.form1.zhanghao.value.length<6)
{
    alert("用户名字符不能少于6位!");
    this.form1.zhanghao.focus();
    return false;
}

BeiTown
2013.06.07

利用JS+CSS去除网站绑定广告

星期日, 十二月 30th, 2012 76 views

应Eric同学邀请,出手帮忙去掉免费服务器的一个附带广告。广告如下,是一个右下角悬浮广告:

用火狐FireBug看了一下源码,该广告的代码如下:


(更多…)