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.Past 6 months Validation from Current Date in JavaScript<p>Hi&nbsp;nauna,</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;script type=&#34;text/javascript&#34;&gt; function ValidateDOB(sender, args) { var dateString = document.getElementById(sender.controltovalidate).value; var regex = /(((0|1)[0-9]|2[0-9]|3[0-1])\/(0[1-9]|1[0-2])\/((19|20)\d\d))$/; if (regex.test(dateString)) { var parts = dateString.split(&#34;/&#34;); var dt = new Date(parts[1] + &#34;/&#34; + parts[0] + &#34;/&#34; + parts[2]); var dtCurrent = new Date(); dtCurrent.setMonth(dtCurrent.getMonth() - 6); if (dt.getFullYear() &lt;= dtCurrent.getFullYear()) { if (dt &gt; dtCurrent) { args.IsValid = true; } else { args.IsValid = false; } } } else { sender.innerHTML = &#34;Enter date in dd/MM/yyyy format ONLY.&#34; args.IsValid = false; } } &lt;/script&gt; &lt;asp:TextBox ID=&#34;txtDate&#34; runat=&#34;server&#34; Text=&#34;02/07/2018&#34; /&gt; &lt;asp:CustomValidator ID=&#34;cvDate&#34; runat=&#34;server&#34; ClientValidationFunction=&#34;ValidateDOB&#34; ControlToValidate=&#34;txtDate&#34; ErrorMessage=&#34;Candidate has not worked for 6 months.&#34; ValidationGroup=&#34;gp1&#34; Display=&#34;Dynamic&#34; ForeColor=&#34;Red&#34; /&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:Button ID=&#34;btnValidate&#34; Text=&#34;Validate&#34; runat=&#34;server&#34; ValidationGroup=&#34;gp1&#34; /&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/4zrXFSa.gif" alt="" width="472" height="161" /></span></strong></p>https://www.aspforums.net:443/Threads/215976/Past-6-months-Validation-from-Current-Date-in-JavaScript/https://www.aspforums.net:443/Threads/215976/Past-6-months-Validation-from-Current-Date-in-JavaScript/Wed, 02 Jan 2019 02:20:29 GMT