c# - set value in text box not more than 2 decimal places -
i have 1 text box allow user key in value decimal value.how set in text box can enter 2 decimal places. now, user can key in more 2 decimal places. below code text box:
<td><b>payment amount:</b></td> <td colspan="2"> <asp:textbox id="txtpayment" runat="server" enabled="true" cssclass="form-control"/> <asp:requiredfieldvalidator id="rfvpayment" runat="server" controltovalidate="txtpayment" validationgroup="submitgroup" display="dynamic" errormessage="* please fill in section" /> <asp:rangevalidator id="rgpayment" runat="server" controltovalidate="txtpayment" display="dynamic" type="double"/> </td>
for text box, on id=rgpayment, use rangevalidator validate value. here code:
protected void lnkbtnb2cproceed_click(object sender, eventargs e) { rgpayment.maximumvalue = "30000"; rgpayment.minimumvalue = "1"; txtpayvia.text = "retail banking"; if (checkamount()) { proceed(resources.default.fpxmsgtokenb2c); trsupportedchannel.visible = false; } } protected void lnkbtnb2bproceed_click(object sender, eventargs e) { rgpayment.maximumvalue = "1000000"; rgpayment.minimumvalue = "2"; txtpayvia.text = "corporate banking (fpx)"; if (checkamount()) { proceed(resources.default.fpxmsgtokenb2b); trsupportedchannel.visible = false; } }
thank you
you can download jquery numeric mask plugin , add it's reference on page. use
$('[id*="txtpayment"]').numeric({ decimal : ".", negative : false, scale: 2 });
Comments
Post a Comment