<html>
<head>
<script>
function AutoCreatePoint(objectLocation){
var object_value=objectLocation.value;
var object_length=objectLocation.value.length;
if (!(object_value.match(/^\d+([.](\d+)?)?$/) || object_value.match(/^[.]\d+$/))){
return;
}
if(object_value!=""){
object_length=object_length-1;
var object_location=object_value.indexOf(".");
if(object_location==-1&&object_value!==""){
objectLocation.value=object_value+".00";
}else if(object_location==0){
objectLocation.value="0"+object_value;
}else if(object_location==object_length){
objectLocation.value=object_value+"00";
}
}
}function isChinese(input)
{
var isChinese=true;
for(var i=0;i<input.length;i++)
{
if(!(input.charCodeAt(i)>=0x4E00&&input.charCodeAt(i)<=0x9FFF))
{
isChinese=false;
}
}
return isChinese;
}
</script>
</head>
<body>
<form>
<input type="text" onchange="javascript:if(!isChinese(this.value)){AutoCreatePoint(this);}" />
</form>
</body>
</html>
<head>
<script>
function AutoCreatePoint(objectLocation){
var object_value=objectLocation.value;
var object_length=objectLocation.value.length;
if (!(object_value.match(/^\d+([.](\d+)?)?$/) || object_value.match(/^[.]\d+$/))){
return;
}
if(object_value!=""){
object_length=object_length-1;
var object_location=object_value.indexOf(".");
if(object_location==-1&&object_value!==""){
objectLocation.value=object_value+".00";
}else if(object_location==0){
objectLocation.value="0"+object_value;
}else if(object_location==object_length){
objectLocation.value=object_value+"00";
}
}
}function isChinese(input)
{
var isChinese=true;
for(var i=0;i<input.length;i++)
{
if(!(input.charCodeAt(i)>=0x4E00&&input.charCodeAt(i)<=0x9FFF))
{
isChinese=false;
}
}
return isChinese;
}
</script>
</head>
<body>
<form>
<input type="text" onchange="javascript:if(!isChinese(this.value)){AutoCreatePoint(this);}" />
</form>
</body>
</html>
var object_value=objectLocation.value;
var object_length=objectLocation.value.length;
if (!(object_value.match(/^\d+([.](\d+)?)?$/) || object_value.match(/^[.]\d+$/))){
alert('false');
return;
}
object_length=object_length-1;
var object_location=object_value.indexOf(".");
if(object_location==-1){
// no decimal point
objectLocation.value=object_value+".00";
}else if(object_location==0){
// the first is decimal point
objectLocation.value="0"+object_value;
}else if(object_location==object_length){
// the last is decimal point
objectLocation.value=object_value+"00";
}else if (object_value.replace(/\d+[.]/, "").length < 2){
// the middle is decimal point
objectLocation.value=object_value+"0";
}
}
连续的数字
连续的数字+小数点
连续的数字+小数点+连续的数字
小数点+连续的数字var object_value=objectLocation.value;
if (!(object_value.match(/^\d+([.](\d+)?)?$/) || object_value.match(/^[.]\d+$/))){
alert('false');
return;
}