标题: jquery特效之金额文本框代码 [打印本页] 作者: 郑鹏 时间: 2012-11-2 13:04 标题: jquery特效之金额文本框代码 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MoneyBox.aspx.cs" Inherits="MoneyBox" %>
<!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 runat="server">
<title>无标题页</title>
<script type="text/javascript">
function numKeyDown(){
var k=window.event.keyCode;
return isValid(k);
}
function isValid(k){
return((k==9)||(k==13)||(k==46)||(k==8)||(k==110)||(k==190)||(k==189)||(k==109)||(k>=37&&k<=40)||(k>=48&&k<=57)||(k>=96&&k<=105));
}
function numPaste(){
var data=clipboardData.getData('Text');
for(var i=0;i<=data.length;i++){
var num=data.charCodeAt(i);
if(!isValid(num))
{
return false;
}
}
}
function commafy(n){
var re=/\d{1,3}(?=(\d{3})+$)/g;
var n1=n.replace(/^(\d+)((\.\d+)?)+$/g,function (s,s1,s2){return s1.replace(re,"$&,")+s2;});
return n1;