User-719153870 posted
Hi aspvbnet,
According to your description, you want to control the data entered into textbox to keep two decimal places. I recommend using JS and regular expressions.
First, make sure that the input is a number, and then remove the excess decimal parts.
Please refer to codes below:
<script type="text/javascript">
function num(obj) {
obj.value = obj.value.replace(/[^\d.]/g, ""); // Clear Characters Other than Numbers and'. '
obj.value = obj.value.replace(/^\./g, ""); // Verify that the first character is a number
obj.value = obj.value.replace(/\.{2,}/g, "."); //Retain only the first . and remove the redundant
obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); // Only two decimal digits can be entered
}
</script>
<div>
Test: 50.0000, 60000.000
<input name="ctl00$Main_content$ucIndEmpHistory$txtSalary" type="text"
id="Text1" onkeyup="num(this)" onpaste="num(this)"
style="width: 100px; text-align: right;" wiid="C1286" runat="server" />
</div>
Hereis result of my demo:

Best Regards,
Yang Shen