My Regular Expressions knowledge is next to none but I'm having to have some client-side valiation against a text box which only allows numbers up to two decimal points with no other input. This script was a basis for entering numeric values only, however it needs to be adapted so it can take a decimal point followed by only up to two decimal places.
I've tried things such as /[^\d].\d{0,2} but then the replacement call wouldn't work, and I've got no idea how to do it.
<script type="text/JavaScript">
function valid(f) {
if (!/^\d*$/.test(f.value)) {
f.value = f.value.replace(/[^\d]/g,"");
alert("Invalid number");
}
}
</script>