ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.CustomValidator for Decimal Number using JavaScript in ASP.Net<p>Hi&nbsp;<a class="username" rel="nauna">nauna,</a></p> <p>With&nbsp;RegularExpressionValidator it is not possible. For this you need to use&nbsp;CustomValidator and write your own logic.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;asp:TextBox runat=&#34;server&#34; ID=&#34;txtofferrate&#34; /&gt; &lt;asp:CustomValidator ID=&#34;CustomValidator1&#34; runat=&#34;server&#34; ClientValidationFunction=&#34;Validate&#34; CssClass=&#34;validation&#34; Display=&#34;Dynamic&#34; ControlToValidate=&#34;txtofferrate&#34; ErrorMessage=&#34;&#34; ForeColor=&#34;Red&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">JavaScript</span></strong></p> <pre class="brush: js">&lt;script type=&#34;text/javascript&#34;&gt; function Validate(sender, args) { var offerRate = document.getElementById(sender.controltovalidate).value; var regex = /^[0-9]\d*(\.\d+)?$/; if (regex.test(offerRate)) { if (offerRate.split(&#39;.&#39;).length &gt; 1) { var value = offerRate.split(&#39;.&#39;)[0]; if (parseInt(value) == 0) { if (value.length &gt; 1) { sender.innerHTML = &#34;Valid Decimal Point Required.&#34; args.IsValid = false; } } } else { args.IsValid = true; } } else { sender.innerHTML = &#34;Valid Decimal Point Required.&#34; args.IsValid = false; } } &lt;/script&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/2MRNTZr.gif" alt="" width="391" height="105" /></span></strong></p>https://www.aspforums.net:443/Threads/187911/CustomValidator-for-Decimal-Number-using-JavaScript-in-ASPNet/https://www.aspforums.net:443/Threads/187911/CustomValidator-for-Decimal-Number-using-JavaScript-in-ASPNet/Thu, 13 Jun 2019 03:12:04 GMT