六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 164|回复: 0

【转】js 数字验证 火狐 文本框获得焦点 文本框处于选中状态

[复制链接]

升级  24%

78

主题

78

主题

78

主题

举人

Rank: 3Rank: 3

积分
272
 楼主| 发表于 2013-2-7 19:42:43 | 显示全部楼层 |阅读模式
http://chengxuyuanbiji.blog.163.com/blog/static/1824565062011444832369/

<!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/xhtml">
<head>
<title>实现代码预览效果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script>
function check(obj){
if(obj.value!=""){
  if(isNaN(obj.value)){  // isNaN -->is not a number 判断是不是数字 是返回true 不是返回false
   alert("请填写数字!");
   obj.focus();
   obj.select();
   window.setTimeout( function(){ obj.focus();obj.select(); }, 0);  //为了兼容火狐加的
  }
}
}
</script>

<input type="input"  />


</body>
</html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表