<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
</head>
<body>
<input type="text" class="text3-2-text">
<input type="submit" class="text3-2-submit">
</body>
</html>
<script>
var tes = $(".text3-2-text");
var btn = $(".text3-2-submit");
btn.click(function() {
var input = parseFloat(tes.val());
tes.val(input);
console.log(input);
var te = /^[0-9]+(\.[0-9]+)?$/;
if (!te.test(input)) {
tes.val('')
};
});
tes.keyup(function(e) {
var bb = tes.val();
var len = bb.length;
var leng = bb.replace(/\./g,'').length;
if (len - leng == 2) {
tes.val('')
};
var te = /^[0-9]+(\.[0-9]+)?$/;
if (e.keyCode == '110' || e.keyCode == '190') {
}
else{
if (!te.test(tes.val())) {
tes.val('')
};
};
});
</script>