<html>
<head>
<title>100以内小数保留一位</title>
<script src="js/jquery1.9.js" type="text/javascript"></script>
</head>
<body>
<input id="c" type="text" value="" /><input id="d" type=text value="" style='background-color:rgb(241, 239, 238);outline:none;border:none;display:none;color:red; ' />
<script type="text/javascript">
jQuery("#c").keyup(function() {
confirmdata("c","--");
});
function confirmdata(confirmid,whichone){
var ex = /^(100|[1-9]?\d(\.\d))$/;
var vl = document.getElementById(confirmid).value;
var x = ex.test(vl);
var r = x?"匹配":"不匹配";
if(vl=='100'){
r = '不匹配';
jQuery("#"+confirmid+"").css({
"color" : "#ff0000"
});
jQuery("#"+confirmid+"").attr("name","unpass");
jQuery("#d").show();
jQuery("#d").val(whichone +"不匹配");
}
if(r == '不匹配'){
jQuery("#"+confirmid+"").css({
"color" : "#ff0000"
});
jQuery("#"+confirmid+"").attr("name","unpass");
jQuery("#d").show();
jQuery("#d").val(whichone +"不匹配");
}else if(r =='匹配'){
jQuery("#"+confirmid+"").css({
"color" : "#000000"
});
jQuery("#"+confirmid+"").attr("name","pass");
jQuery("#d").val(whichone +"匹配");
jQuery("#d").hide();
}
if(vl=='0'){
jQuery("#"+confirmid+"").css({
"color" : "#000000"
});
jQuery("#"+confirmid+"").attr("name","pass");
jQuery("#d").val(whichone +"匹配");
jQuery("#d").hide();
}
}
</script>
</body>
</html>
<head>
<title>100以内小数保留一位</title>
<script src="js/jquery1.9.js" type="text/javascript"></script>
</head>
<body>
<input id="c" type="text" value="" /><input id="d" type=text value="" style='background-color:rgb(241, 239, 238);outline:none;border:none;display:none;color:red; ' />
<script type="text/javascript">
jQuery("#c").keyup(function() {
confirmdata("c","--");
});
function confirmdata(confirmid,whichone){
var ex = /^(100|[1-9]?\d(\.\d))$/;
var vl = document.getElementById(confirmid).value;
var x = ex.test(vl);
var r = x?"匹配":"不匹配";
if(vl=='100'){
r = '不匹配';
jQuery("#"+confirmid+"").css({
"color" : "#ff0000"
});
jQuery("#"+confirmid+"").attr("name","unpass");
jQuery("#d").show();
jQuery("#d").val(whichone +"不匹配");
}
if(r == '不匹配'){
jQuery("#"+confirmid+"").css({
"color" : "#ff0000"
});
jQuery("#"+confirmid+"").attr("name","unpass");
jQuery("#d").show();
jQuery("#d").val(whichone +"不匹配");
}else if(r =='匹配'){
jQuery("#"+confirmid+"").css({
"color" : "#000000"
});
jQuery("#"+confirmid+"").attr("name","pass");
jQuery("#d").val(whichone +"匹配");
jQuery("#d").hide();
}
if(vl=='0'){
jQuery("#"+confirmid+"").css({
"color" : "#000000"
});
jQuery("#"+confirmid+"").attr("name","pass");
jQuery("#d").val(whichone +"匹配");
jQuery("#d").hide();
}
}
</script>
</body>
</html>