Chinaunix首页 | 论坛 | 博客
  • 博客访问: 347646
  • 博文数量: 76
  • 博客积分: 2790
  • 博客等级: 少校
  • 技术积分: 882
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-13 09:15
个人简介

Will do as will say

文章分类

全部博文(76)

文章存档

2013年(7)

2012年(13)

2011年(2)

2009年(2)

2008年(52)

我的朋友

分类: Java

2008-08-13 11:10:48

1. 长度限制
<script>
function test()
{
if(document.a.b.value.length>5)
{
alert("不能超过50个字符!");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"></textarea>
<input type="submit" name="Submit" value="check">
</form>


2. 屏蔽关键字(这里屏蔽*******)
<script language="javascript1.2">
function test() {
if((a.b.value.indexOf ("***") == 0)||(a.b.value.indexOf ("****") == 0)){
alert(":)");
a.b.focus();
return false;}
}
</script>
<form name=a onsubmit="return test()">
<input type=text name=b>
<input type="submit" name="Submit" value="check">
</form>


3. 两次输入密码是否相同
<FORM METHOD=POST ACTION="">
<input type="password" id="input1">
<input type="password" id="input2">
<input type="button" value="test" onclick="check()">
</FORM>
<script>
function check()
{
with(document.all){
if(input1.value!=input2.value)
{
alert("false")
input1.value = "";
input2.value = "";
}
else document.forms[0].submit();
}
}
</script>

4.屏蔽右键
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">
加在body中
</body>


5.复制文本到剪帖板
<input title="点击复制标题和地址到剪贴版,直接在POPO/MSN上粘贴即可." type=button value="点击复制本网址,发给POPO/QQ/MSN好友共享" name="B3" onclick="copyToClipBoard()">
<script language='javascript'>
function copyToClipBoard(){
var clipBoardContent='';
clipBoardContent+=document.title;
clipBoardContent+=window.location;
window.clipboardData.setData("Text",clipBoardContent);
alert("你已复制链接及标题,请粘贴到POPO/MSN等发给好友!");
}
</script>


6.载入页面

<title>载入页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.unnamed1 { background-color: #000000}
-->
</style>
</head>
<body>
<table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%">
<tr>
<form name=loading>
      <td align=center>
        <p align="center">&nbsp;</p>
        <p align="center"><font color="#00FF00" size="2"></font></p>
        <p>
          <input type=text name=chart size=46 style=
"font-family:Arial; font-weight:bolder;
color:#00FF00; background-color:black; padding:0px; border-style:none;"
>
          <br>
          <br>
          <input type=text name=percent size=46 style=
"font-family:Arial; color:#00FF00;
text-align:center; border-width:medium; border-style:none;"
class="unnamed1">
          <br>
          <br>
          <font color="#00FF00" size="2" >
          <script>
var bar = 0
var line = "||"
var amount ="||"
count()
function count(){
bar= bar+2
amount =amount + line
document.loading.chart.value=amount
document.loading.percent.value=bar+"%"
if (bar<99)
{
setTimeout("count()",100);
}
else
{
alert("载入完毕")
window.location = "";
}
}
</script>
</font></p>
         </td>
</form>
</tr>
</table>
</body>
</html>

阅读(2247) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~