所谓输入掩码技术,即只有数字键起作用

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <style type="text/css">
#switcher input{height:26px;width:200px;}
    
    </style>
    <script src="./jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#switcher input").keypress(function(event){
    if(event.which && (event.which < 48 || event.which >57)){
        event.preventDefault();
    }
});
});
</script>
  </head>
  
  <body>
<div id="switcher">
<input type="text" value="只能输入数字的输入掩码技术" id="txt" maxlength="150" name="txtname"  onfocus="this.value=(this.value=='只能输入数字的输入掩码技术') ? '' : this.value;" onblur="this.value=(this.value=='') ? '只能输入数字的输入掩码技术' : this.value;"/>
</div>
</body>
</html>

 

posted @ 2014-06-14 12:02  充实地生活着  阅读(391)  评论(0)    收藏  举报